Hi,
I draw a black background.
Then I draw an opaque image.
And over this image I draw a 50% white transparent image.
In my OpenGLView everything looks RIGHT:
The background color is lighter just under the transparent image.
The opaque image is ligther too under the transparent image.
Then I save this image to a PNG or TIFF file and... surprise!
The pixels under the 50% trasparent image are totally 50% transparent.
I mean that Photoshop shows the checked gray/white pattern.
The black background should not become 50% trasparent but 50% lighter, as
shown in my OpenGL view.
What did I do wrong?
I show you some code.
PixelFormat ----------------------
NSOpenGLPFANoRecovery,
NSOpenGLPFAWindow,
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorSize, 32,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFASingleRenderer,
NSOpenGLPFAScreenMask,
CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
NSOpenGLPFAClosestPolicy...
glClearDepth(1.0f);
I draw ---------------------------
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// I draw...
[[self openGLContext] flushBuffer];
Read the image buffer -------------
NSBitmapImageRep *bitMap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:(unsigned char**)NULL
pixelsWide:width
pixelsHigh:height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:kSamplesPerPixel * width
bitsPerPixel:32];
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
glReadBuffer(GL_BACK);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
[bitMap bitmapData]);
NSData *pngData = [bitMap representationUsingType:NSPNGFileType
properties:nil];
if(pngData){
[pngData writeToFile:@"/image.png" atomically:YES];
}
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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