I was thinking the same thing. Maybe Im grabbing it
ok, but displaying it wrong. Anyway, here is the meat
of the code. I hope the formatting on this comes out
ok:
The baseline code I used is here:
http://lists.apple.com/archives/cocoa-dev/2005/Aug/msg00901.html
This returns a CFImageref. The only difference I made
here is changing the GL_UNSIGNED_INT_8_8_8_8_REV to
GL_UNSIGNED_INT_8_8_8_8
I display with the code here (I removed error checking
to make it shorter):
CGContextRef MyCreateBitmapContext (int pixelsWide,
int pixelsHigh, int*
num_bytes)
{
...
bitmapBytesPerRow = (pixelsWide * 4);
bitmapByteCount = (bitmapBytesPerRow *
pixelsHigh);
colorSpace = CGColorSpaceCreateWithName
(kCGColorSpaceGenericRGB);
*num_bytes = bitmapByteCount;
bitmapData = malloc( bitmapByteCount );
context = CGBitmapContextCreate (bitmapData,
pixelsWide,
pixelsHigh,
8,
bitmapBytesPerRow,
colorSpace,
kCGImageAlphaNoneSkipFirst);
CGColorSpaceRelease( colorSpace );
return context;
}
main() {
...
//display the image at 50% of original size
myImageArea = CGRectMake (0,0,width, height);
myRect = CGRectMake (0,0,width * .5, height * .5);
small_context = MyCreateBitmapContext(width * .5,
height * .5,&num_bytes);
bah = grabViaOpenGL(kCGDirectMainDisplay ,
myImageArea); mySubImage=
CGImageCreateWithImageInRect(bah, myImageArea);
CGContextDrawImage(small_context, myRect, mySubImage);
bah_small = CGBitmapContextCreateImage
(small_context);
CFRelease(bah);
CGDisplayCaptureWithOptions
(kCGDirectMainDisplay,kCGCaptureNoFill);
ctx = CGDisplayGetDrawingContext
(kCGDirectMainDisplay);
CGContextDrawImage(ctx, myRect, mySubImage);
sleep (1);
CGDisplayRelease (kCGDirectMainDisplay);
}
-Thorrin
--- Shawn Erickson <email@hidden> wrote:
>
> On Feb 15, 2007, at 7:54 PM, Thorrin wrote:
>
> > Thanks for the reply!
> >
> > I integrated your code into what I had, but the
> > results are still the same. It looks like the
> only
> > real differences are that you use
> > vImageVerticalReflect_ARGB8888 instead of the
> swizzle
> > bytes routine that I had, and your
> GL_PACK_ROW_LENGTH
> > value is different... I will have to step through
> > with the debugger and see what the bytes look like
> in
> > memory to determine what is really going on there.
> >
> > I will say that I didn't know about the vImage
> > routines before hand, so that is something to look
> > into. Also, I will look into some of the byte
> > swapping routines that Eric Wing mentioned in a
> > different email.
>
> You shouldn't have to do any byte swapping and if
> you do need to look
> at vImage for that (vImagePermuteChannels of course
> that function is
> 10.4 and later).
>
> It may help if you post a cut down but working code
> example of the
> problem you are seeing. I have a feeling it isn't
> the grab side of
> things that is the problem but how you are turning
> that buffer into
> an image.
>
> -Shawn
>
"Everyone is allergic to giant rocks hitting them in the head!"
-Thorrin's elf chick after casting a 'meteor swarm' spell ;)
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden