Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gluScaleImage with NSBitmapImageRep



On Nov 1, 2004, at 2:06 PM, email@hidden wrote:

I think your right.
I changed the code so that it is now:

gluScaleImage(imageType, [imageRep pixelsWide], [imageRep pixelsHigh],
GL_UNSIGNED_BYTE,[imageRep bitmapData], 256, 256, GL_UNSIGNED_BYTE,
[bmpResizedImage bitmapData]);

This seems to be on the right track, but it does not solve the problem
entirely. It still crashes out the program, but before it does, all of the
objects go black, and then it will crash.


I also added:

[bmpResizedImage setPixelsHigh:256];
[bmpResizedImage setPixelsWide:256];

since I was thinking that alloc might not be allocating the right amount of
space and causing the program to crash. But I'm really not sure.

Try mallocing a buffer of the proper size and passing it to gluScaleImage and see if that works. If not maybe there is a problem with your source image.


You could see what was going on if you stop in the debugger and see what the value of the [imageRep bitmapData] is. My money would on it being NULL. I don't think you can just alloc a NSBitmapImageRep and set its size to get it to allocate storage. I think you need to do something like this:

bmpResizedImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:256
pixelsHigh:256
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:(256*4)
bitsPerPixel:0];


Then pass the [imageRep bitmapData] to gluScaleImage. Go to http://cocoadev.com and search for initWithBitmapDataPlanes to see some examples.

Also you need to make sure that you set up the OpenGL pixel storage modes are set up correctly before you call gluScaleImage (see glPixelStore). In particular GL_UNPACK_ALIGNMENT and GL_PACK_ALIGNMENT seem to bite me once in a while. Unpack is for your buffers that OpenGL reads (your source data). Pack is for the buffers OpenGL writes (your destination).

Kent

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.