Be sure your width and height are not related to some variable you didn't
updated afer resizing the window... I see that you get
NSRect sceneFrame = [fractalView frame];
from the fractal view while, in the call "getBitMap:" you get
NSRect sceneFrame = [self frame];
from some vie else...
Also, try to put
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);
glFinish();
before
[fractalView getBitMap:imageBitMap];
And, try to get the TIFFRepresentation, then save it.
NSImage *anImage;
anImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
[anImage addRepresentation:[imageBitMap autorelease]];
[anImage setFlipped:YES];
NSData *tiffData ;
tiffData = [anImage TIFFRepresentationUsingCompression:
NSTIFFCompressionLZW
factor: 15.0];
[tiffData writeToFile:@"/aFileName.tif" atomically:YES];
Best Regards
--
Lorenzo
email: email@hidden
> From: email@hidden
> Reply-To: email@hidden
> Date: Thu, 08 Jul 2004 22:00:37 -0700
> To: email@hidden
> Subject: mac-opengl digest, Vol 3 #993 - 5 msgs
>
> Send mac-opengl mailing list submissions to
> email@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://www.lists.apple.com/mailman/listinfo/mac-opengl
> or, via email, send a message with subject or body 'help' to
> email@hidden
>
> You can reach the person managing the list at
> email@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of mac-opengl digest..."
>
>
> Today's Topics:
>
> 1. Re: Drawing k2vuyPixelFormat data using GL_APPLE_ycbcr_422 (Philip Lamb)
> 2. glReadPixels maxing out? (john gale)
> 3. Cg framework questions (Matthew Giger)
> 4. Re: Distributing the Cg runtime with my plugin? (Jonathan del Strother)
> 5. re: Disabling card features (Jeff Ray)
>
> --__--__--
>
> Message: 1
> Date: Thu, 08 Jul 2004 17:41:55 +1200
> From: Philip Lamb <email@hidden>
> Subject: Re: Drawing k2vuyPixelFormat data using GL_APPLE_ycbcr_422
> To: Daniel Heckenberg <email@hidden>, Mac OpenGL List
> <email@hidden>, Chris Clepper <email@hidden>
>
> At 3:56 PM +1200 6/11/04, Philip Lamb wrote:
>>>> At the moment I am working on optimising some code which captures from
>>>> an IIDC digital camera (to a GWorld in a typical son-of_munggrab way,
>>>> but using OpenGL to display rather via a rectangle texture rather than
>>>> QuickDraw.)
>>>>
>>>> The optimisation I am making is to use a k2vuyPixelFormat GWorld and
>>>> then use OpenGL to draw using the GL_APPLE_ycbcr_422 extension.
>>>>
>>>> However, I am running into problems. Specifically, the image drawn by
>>>> OpenGL is incorrect, and it draws as if two half-width
>>>> green-and-purple tinted images have been placed side by side in the
>>>> window.
>>
>> Thanks to Daniel and Chris for their samples, both of which work for
>> them but produce identical results to mine when run on my machine.
>> I've also managed to verify that its not an issue with my camera or
>> its drivers.. as when I draw the YCbCr pixels using glDrawPixels
>> they draw correctly (albiet very slowly.)
>>
>> So it looks like I've uncovered a bug in the GL_APPLE_ycbcr_422
>> extension for textures at least on my configuration.. GeForce 4MX,
>> dual displays, G4 (MDD).
>> --
>
> So to follow up on my own post..
>
> I have identified the regression under which GL_APPLE_ycbcr_422 (YUV)
> OpenGL textures are drawn as if they were just regular RGB textures
> (resulting in two half-width green and purple images being drawn) --
> it is when the GL_APPLE_texture_range extension is active. If I make
> no calls to glTextureRangeAPPLE() then my GL_APPLE_ycbcr_422 textures
> are drawn as expected.
>
> So a heads up for folks using GL_APPLE_ycbcr_422 OpenGL textures, and
> I will file a bug on this now that I've identified the regression.
>
> --
> Philip Lamb
>
> --__--__--
>
> Message: 2
> To: Mac List <email@hidden>
> From: john gale <email@hidden>
> Subject: glReadPixels maxing out?
> Date: Wed, 7 Jul 2004 23:17:02 -0700
>
> I have an application that uses a glReadPixels call to form an
> NSBitmapImageRep and export that to a file, for saving an opengl scene
> to a jpeg. It's worked wonderfully up until WWDC... where I was
> fortunate enough to run my app on the beautiful new 30" displays. When
> I expanded the window (scene) to maximum size, filling up all 4 million
> pixels with the scene, it looked amazingly perfect, but when I exported
> that (piping through glReadPixles and all that jazz) the jpeg image
> that was formed was cropped. What's interesting is that the jpeg image
> export is the correct size that it should be, but 3/4 down the image, a
> line of pixels stops and the rest of the image is shown as plain black
> (which happens to be the background color of the scene).
>
> What I find curious is that the scene rendered perfectly in the window,
> and was cropped only in the export. This suggests to me that there may
> be a maximum buffer in the glReadPixels call, or maybe my
> NSBitmapImageRep is initialized with the wrong size (yet it's worked
> perfectly on all smaller screens). I haven't found any information
> about either subject, and so the last option I suppose is that it's a
> bug which I'd love to file, but I can't get my hands on a 30" display
> again to work with it and isolate it.
>
> Does anybody know of any known problems with the glReadPixels maximum
> reading size? Relevant code snippets can be found below.
>
> Also, as a side comment, is there an easy way to setFlipped on an
> NSBitmapImageRep so that my scene won't be vertically flipped?
>
> Thanks so much in advance,
>
>
> ~ john
>
>
> - (void)getBitMap:(NSBitmapImageRep*)imageBitMap {
> [[self openGLContext] makeCurrentContext];
> // get height and width of scene
> NSRect sceneFrame = [self frame];
> int width = sceneFrame.size.width;
> int height = sceneFrame.size.height;
> // read pixels
> glReadPixels( 0, 0, width, height,
> GL_RGBA, GL_UNSIGNED_BYTE,
> [imageBitMap bitmapData]);
> } // end getBitMap
>
>
> - (IBAction)exportDocument:(id)sender {
> // get scene height and width
> NSRect sceneFrame = [fractalView frame];
> int width = sceneFrame.size.width;
> int height = sceneFrame.size.height;
>
> // alloc the bitmap image
> NSBitmapImageRep *imageBitMap;
> imageBitMap = [[NSBitmapImageRep alloc]
> initWithBitmapDataPlanes:NULL
> pixelsWide:width
> pixelsHigh:height
> bitsPerSample:8
> samplesPerPixel:4
> hasAlpha:YES
> isPlanar:NO
> colorSpaceName:NSCalibratedRGBColorSpace
> bytesPerRow:4 * width
> bitsPerPixel:4 * 8];
>
> // get image
> [fractalView getBitMap:imageBitMap];
> NSData *jpegData = [imageBitMap representationUsingType:NSJPEGFileType
> properties:
> [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.0f]
> forKey:@"NSImageCompressionFactor"]];
>
> NSSavePanel *savePanel = [NSSavePanel savePanel];
> [savePanel setRequiredFileType:@"jpeg"];
> [savePanel setCanCreateDirectories:YES];
> [savePanel setMessage:@"Export fractal image to JPEG file."];
> [savePanel setPrompt:@"Export"];
> [savePanel setTitle:@"Export as JPEG"];
> if ([savePanel runModal] == NSFileHandlingPanelOKButton) {
> if ([jpegData writeToFile:[savePanel filename] atomically:YES])
> {
> //NSLog(@"file written fine.");
> } else {
> NSLog(@"error writing file.");
> NSLog([savePanel filename]);
> } // end if else
> } // end if
>
> [imageBitMap release];
> } // end exportImage
>
>
> =================
> support the arts!
> www.smadness.com
>
> updated May 2 2004
>
> --__--__--
>
> Message: 3
> To: email@hidden
> From: Matthew Giger <email@hidden>
> Subject: Cg framework questions
> Date: Thu, 8 Jul 2004 06:56:46 -0700
>
> I have 2 questions about including Cg.framework in an application.
>
> 1) I am unable to prebind my application since the Cg.framework is not
> prebound. Is there any way for me to get a prebound version of Cg?
>
> 2) Are there any source code examples of a program using Cg with XCode?
> I have been unsuccessful in my searches so far. I will eventually
> figure out all of the steps needed to get it working, but a simple
> working example would be extremely useful...
>
> Thank you.
>
> Matt Giger
> Lunar Software, Inc.
>
> --__--__--
>
> Message: 4
> Cc: email@hidden
> From: Jonathan del Strother <email@hidden>
> Subject: Re: Distributing the Cg runtime with my plugin?
> Date: Thu, 8 Jul 2004 18:46:08 +0100
> To: Keith Bauer <email@hidden>
>
> On 8 Jul 2004, at 0:49, Keith Bauer wrote:
>
>>> Yes, you are allowed to ship Cg with your app. There should have been
>>> a
>>> license included with Cg, if not we'll add one to the next Cg release.
>>>
>>>> I've been trying to get it to work as an
>>>> embedded bundle within my plugin's package, but no luck there just
>>>> yet...
>>
>> it looks like you can use install_name_tool to change where the
>> framework thinks it should be... but since
>> @executable_path/../Frameworks/ is longer than /Library/Frameworks,
>> it's probably not going to work (unless NVidia had the forethought to
>> build it with -headerpad_max_install_names).
>>
>> Looks like you should be able to change it to just @executable_path
>> though, and hopefully therefore be able to put it inside the MacOS
>> directory... not perfect, but perhaps it would work.
>
>
> Ahh, thanks. However....new problem. @executable_path isn't the
> plugin's path - it's iTunes' path. So it works if I put Cg.framework
> in /Applications/iTunes.app/Contents/MacOS, but not in my plugin's
> bundle.
>
>
> Any ideas?
>
> Thanks,
> Jon
>
> --__--__--
>
> Message: 5
> Date: Thu, 8 Jul 2004 14:52:19 -0800
> To: email@hidden
> From: Jeff Ray <email@hidden>
> Subject: re: Disabling card features
>
>> OpenGL profiler allows you to change some of OpenGL Get queries to
>> act like a different card - so the card in the machine will respond
>> like a different one. I think it would be just as easy in your case
>> to just modify your routine that looks for GL_ARB_fragment_program
>> in the extension string so it fails. Of course this won't catch
>> your program doing the wrong thing in that case.
>
> It also won't work for those cases where certain extensions modify
> the behavior of other extensions, such as the interaction of
> rectangle texture and paletted texture; pretending paletted texture
> isn't present doesn't make it's effect on rectangle texture go away.
> --
> ------------------------------------------------------------------
> Jeff Ray M/S 4840A Official Correspondence Only:
> NASA Internet: email@hidden
> Dryden Flight Research Center email@hidden
> P. O. Box 273
> Edwards, CA 93523-0273 All Others: .Mac: email@hidden
> (805) 258-3754 AOL: email@hidden
>
>
> --__--__--
>
> _______________________________________________
> mac-opengl mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/mac-opengl
> Do not post admin requests to the list. They will be ignored.
>
>
>
> End of mac-opengl Digest
_______________________________________________
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