> 
> On 12 Mar '08, at 9:09 AM, Trygve Inda wrote:
> 
>> NSImage *           image = [NSImage imageNamed:@"colorTest"];
>> NSBitmapImageRep *  imageRep = [NSBitmapImageRep imageRepWithData:
>> [image
>> TIFFRepresentation]];
> 
> That will work, I think, but it's sort of inefficient, since it
> requires encoding and decoding TIFF.
> 
> The quickest way would be to look at the NSImage's array of
> imageRepresentations and look for an NSBitmapImageRep of the right
> dimensions. Most types of images have one (the exceptions I can think
> of are PDF, icns and PICT.)
> 
> If that fails, you can create a new empty NSBitmapImageRep, lockFocus
> on it, draw the source image into it, and unlockFocus.
> 
>> What needs to be released and retained in this case? If I release
>> "image",
>> does that also release "imageRep"?
> 
> In your code as give above, you didn't directly alloc or retain
> anything, so there's nothing to release. However, none of the objects
> are guaranteed to exist after the topmost autorelease pool exits. If
> you want to keep a long-term reference you'll need to retain that
> object. (If you want to keep using the raw pixel data, you need to
> retain its owner, the image-rep.)
> 
>> Finally... In my testing I always get the data as RGB with no alpha
>> padding
>> (at least in the jpg case). How can I guarantee this?
> 
> Then you definitely want to create your own NSBitmapImageRep — the
> init method will give you total control over the pixel format. Then
> you can lockFocus and draw whatever you want into it.

So I create an NSBitmapImageRep with:

- (id)initWithBitmapDataPlanes:(unsigned char **)planes
pixelsWide:(NSInteger)width pixelsHigh:(NSInteger)height
bitsPerSample:(NSInteger)bps samplesPerPixel:(NSInteger)spp
hasAlpha:(BOOL)alpha isPlanar:(BOOL)isPlanar colorSpaceName:(NSString
*)colorSpaceName bitmapFormat:(NSBitmapFormat)bitmapFormat
bytesPerRow:(NSInteger)rowBytes bitsPerPixel:(NSInteger)pixelBits

There is a method similar to this without bitmapFormat... How is that
interpreted then?

How than can I draw a jpg into this space?

I will then later need to take this bitmap and create a new jpg with it.

Thanks,

Trygve


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to