Antialising a CGImageRef
Antialising a CGImageRef
- Subject: Antialising a CGImageRef
- From: Tito Ciuro <email@hidden>
- Date: Thu, 20 Feb 2003 15:05:12 +0100
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.