Re: I need float resolution bitmap data from a JPG using CIImage or similar helper
Re: I need float resolution bitmap data from a JPG using CIImage or similar helper
- Subject: Re: I need float resolution bitmap data from a JPG using CIImage or similar helper
- From: David Duncan <email@hidden>
- Date: Tue, 1 Jun 2010 11:16:08 -0700
On May 31, 2010, at 5:40 PM, Robert Lorentz wrote:
> What I REALLY want to achieve (this can be poor performance): take a JPG (or PNG is great too) file on disk, result with a float *bytes; array holding the floating point precision data from the JPG as R G B A format. Anything that achieves that is a solution here - my current route is to use CIImage just because loading up JPG is so easy with it.
You can use ImageIO to do this, just ask for Floating point precision from your images. This is something that you set with the image source options. Something like this (error checking and mem management missing):
CGImageSourceRef src = CGImageSourceCreateWithURL(urlToFile, (CFDictionaryRef)[NSDictionary dictionaryWithObject:[NSNumber numberWithBOOL:YES] forKey:(id)kCGImageSourceShouldAllowFloat]);
CGImageRef img = CGImageSourceCreateAtIndex(src, 0);
> // create a CG context, using my float array to hold it's data. Therefore, IF I draw to it
> // correctly, I should get rawData filled with the bitmap float data of my CIImage
> CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGBitmapFloatComponents);
Are you sure the context was actually created? Specifically for float contexts, you need the kCGImageAlpha[Premultilied | None]Last flag as well.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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