Re: Resolution of an NSImage(Rep)?
Re: Resolution of an NSImage(Rep)?
- Subject: Re: Resolution of an NSImage(Rep)?
- From: Brian Postow <email@hidden>
- Date: Thu, 5 Aug 2010 11:45:55 -0400
Ok, so a little research reveals that the problem is much earlier than I thought: the images I'm creating have no resolution data.
So, the next question is: Given a bunch of bitmap data, and a resolution, how do I create an NSImage (or CGImage or CGImageSource) with the correct resolution?
Currently, I'm doing:
CGDataProviderRef provider= CGDataProviderCreateWithData(NULL, (UInt8*)data, bytesPerRow * length, NULL);
CGImageRef cgImg = CGImageCreate (
width,
length,
bitsPerComponent,
bitsPerPixel,
bytesPerRow,
colorspace,
bitmapinfo, // ? CGBitmapInfo bitmapInfo,
provider, //? CGDataProviderRef provider,
NULL, //const CGFloat decode[],
true, //bool shouldInterpolate,
kCGRenderingIntentDefault // CGColorRenderingIntent intent
);
/* CGColorSpaceRelease(colorspace); */
NSData* imgData = [NSMutableData data];
CGImageDestinationRef dest = CGImageDestinationCreateWithData
(imgData, kUTTypeTIFF, 1, NULL);
CGImageDestinationAddImage(dest, cgImg, NULL);
CGImageDestinationFinalize(dest);
NSImage* img = [[NSImage alloc] initWithData: imgData];
now, it appears that CGImageDestination takes only a NULL argument for the dictionary.. and width and length are in pixels, not points or inches. At what point in this process am I supposed to add the resolution into this process?
Brian Postow
Senior Software Engineer
Acordex Imaging Systems
_______________________________________________
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