[SOLVED]Re: Antialising a CGImageRef
[SOLVED]Re: Antialising a CGImageRef
- Subject: [SOLVED]Re: Antialising a CGImageRef
- From: Tito Ciuro <email@hidden>
- Date: Thu, 20 Feb 2003 20:08:47 +0100
Hi Chris,
The CGImageCreate includes a parameter as to whether drawing the image
will interpolate during the operation.
Thank you very much! That's all it took!
I had forgotten about this parameter... silly me.
Thanks everyone else for answering as well,
-- Tito
On Thursday, February 20, 2003, at 07:55 PM, Chris Meyer wrote:
Hi Tito,
The CGImageCreate includes a parameter as to whether drawing the image
will interpolate during the operation. You should probably check to
make sure that imageFromPNG is setting this parameter correctly when
it creates the image. If you don't have access to imageFromPNG, you
can check it by calling CGImageGetShouldInterpolate on the image in
your code below.
Chris Meyer
LQ Graphics, Inc.
On Thursday, February 20, 2003, at 06:05 AM, Tito Ciuro wrote:
Hello,
I'm trying to draw a CGImageRef like this:
/********************************************/
NSRect cellFrame = [self bounds];
CGContextRef theRef = (CGContextRef)[[NSGraphicsContext
currentContext]
graphicsPort];
// imageFromPNG is defined in a category
CGImageRef iconImage = [NSImage imageFromPNG:@"MyLogo.png"];
CGRect iconRect;
const float iconSize = 32.0;
iconRect = CGRectMake(NSMidX(cellFrame) - (iconSize / 2.0),
NSMidY(cellFrame) - (iconSize / 2.0), iconSize, iconSize);
CGContextSetShouldAntialias(theRef, true);
CGContextDrawImage(theRef, iconRect, iconImage);
CGContextFlush(theRef);
/********************************************/
The code above draws the image in the proper location with the proper
size, but the quality is far from the one we can see in the Dock, for
example. The Dock displays a nice, antialiased image, while the above
code draws it compressing pixels together, resulting in an ugly
render.
Any ideas on how this can be improved?
Thanks,
-- Tito
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.