Re: NSImage vs. NSBitmapImageRep color differences?
Re: NSImage vs. NSBitmapImageRep color differences?
- Subject: Re: NSImage vs. NSBitmapImageRep color differences?
- From: Christopher Nagel <email@hidden>
- Date: Mon, 30 Jun 2003 13:32:01 -0400
On Monday, June 30, 2003, at 11:54 AM, Thomas Finley wrote:
On Monday, June 30, 2003, at 11:10 AM, Christopher Nagel wrote:
// This yields a yellowish image
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, [image size].width,
[image size].height, 0, GL_RGB, GL_UNSIGNED_BYTE,
[[image TIFFRepresentation] bytes] );
Yeah, that won't work, but why would you expect it to? GL accepts raw
pixel data for a texture, which a TIFFRepresentation will not provide
-- this code is functionally equivalent to dumping the raw data of a
TIFF file for use as a GL texture.
Well, in my limited understanding of TIFFs, I assumed it was basically
a bitmap format (as opposed to jpeg or png). I guess I wasn't *too*
far off, huh? :-)
This brings the question for me though - when you say 'raw pixel data'
does this imply a device-dependent representation, further implying
that some massaging has to happen for each different
architecture/graphics card?
The only reason I can imagine why it even almost seems to work is
because TIFFRepresentation probably produces an image without
compression, which must be close enough to the raw pixels to resemble
the image somehow.
Yet NSBitmapImageRep is initialized with TIFFRepresentation.
That shouldn't matter. You could initialize it with any
representation you like, and bitmapData would always returns the raw
pixels.
I was trying to avoid the overhead of creating the NSBitmapImageRep,
just for kicks.
You might check if [image representations] already has a bitmap image
rep rather than always creating one. WIth many types of files (i.e.
TIFFs, JPEGs, BMPs, etc) that representation will already exist in the
image, and only in cases where it does not exist would you be forced
to create the rep.
Well, actually I did this:
(gdb) po [image representations]
<NSCFArray 0x1923160>(
NSBitmapImageRep 0x1923080 Size={128, 128}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=128x128 Alpha=NO
)
However I had forgotten to send -bitmapData to it so I wasn't getting
anything useful. Now that my code is this, it works fine. Thanks!
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, [image size].width,
[image size].height, 0, GL_RGB, GL_UNSIGNED_BYTE,
[[[image representations] objectAtIndex:0]
bitmapData]);
// It still remains to be seen if there's any gain in doing it this
way, though...
Thanks again,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.