• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to write ipeg image created with CGImageRef?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to write ipeg image created with CGImageRef?


  • Subject: Re: How to write ipeg image created with CGImageRef?
  • From: Scott Thompson <email@hidden>
  • Date: Fri, 10 Jul 2009 13:25:36 -0500

I'm trying to save an NSBitmapImageRep initialized with - initWithCGImage: onto a disk.

But the image of the saved file is bad. This means only black and white horizontal lines are drawn meaninglessly.

The _rep in the below code is the NSBitmapImageRep instance allocated and initialized with -initWithCGImage: as I said at the beginning,
and the image rep has alpha.


- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
NSDictionary* properties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:0.7], NSImageCompressionFactor,
[NSNumber numberWithBool:YES], NSImageProgressive, nil];

NSData* result = [_rep representationUsingType:NSJPEGFileType properties:properties];
return result;
}


The NSBitmapImageRep is logged like the following:
0x15ce70 Size={400, 264} ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=32 Pixels=400x264 Alpha=YES Planar=NO Format=2


Would you tell me what I'm missing?

Thank you for reading this message.

Instead of taking the CGImage into NSImage and then exporting the NSImage, you might just use ImageIO to save the CGImage directly. Look up CGImageDestination in the documentation and see if you get better results using it to export as JPEG.


Scott

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >How to write ipeg image created with CGImageRef? (From: norio ota <email@hidden>)

  • Prev by Date: Re: NSCondition (unlocked when not locked)
  • Next by Date: Re: how to hide/display titlebar?
  • Previous by thread: How to write ipeg image created with CGImageRef?
  • Next by thread: Cocoa Frontend to SDL App
  • Index(es):
    • Date
    • Thread