Re: CGImageRef to bitmap context?
Re: CGImageRef to bitmap context?
- Subject: Re: CGImageRef to bitmap context?
- From: Scott Thompson <email@hidden>
- Date: Mon, 13 Aug 2007 08:46:32 -0500
On Aug 12, 2007, at 10:30 PM, Mike McNamara wrote:
Hello all -
I've been using the handy glgrab.c code:
http://www.cocoabuilder.com/archive/message/cocoa/2005/8/13/144256
for grabbing captures of small portions of the screen. Very handy!
My app in fact works fine, except for the fact that the captured
screen portion is not really a good pixel for pixel representation
when I magnify it. At first I thought the capture was simply being
antialiased somehow and as such tried all sorts of voodoo to
eliminate that. However that appears to be a dead end. It now seems
probable to me that my issue has something to do with the fact that
the CGImageRef returned by grabViaOpenGL() in glgrab.c is not a
bitmap style image and as such does not scale up like a bitmap
would? Am I headed down the right road here?
CGImageRef is certainly a "bitmap style image". All CGImages
represent a rectangular array of color samples (i.e. pixels).
How are you magnifying the image? With Quartz 2D? With OpenGL?
I suspect that when you scale the image, the system is using
interpolation to create the resulting image and you are
misinterpreting the interpolation artifacts.
Is there an easy / efficient way to convert the original sized
CGImageRef to a bitmap context and scale up as needed from there?
Sure. Create a CGBitmapContext that's as large as you like, set it's
scale using CGContextScaleCTM and then draw the image. If you don't
want interpolation artifacts, use CGContextSetInterpolationQuality
with kCGInterpolationNone.
http://developer.apple.com/qa/qa2007/qa1509.html
but openly admit that I am having difficulty seeing how I would
apply it to my situation.
Well, it provides a sketch of the way to get an image into a
CGBitmapContext.
Scott
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden