• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Antialising a CGImageRef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Antialising a CGImageRef
      • From: Chris Meyer <email@hidden>
    • Re: Antialising a CGImageRef
      • From: Stéphane Sudre <email@hidden>
  • Prev by Date: [NSTableView] Is this a OS X 10.2 bug in NSTableView?
  • Next by Date: Re: Antialising a CGImageRef
  • Previous by thread: [NSTableView] Is this a OS X 10.2 bug in NSTableView?
  • Next by thread: Re: Antialising a CGImageRef
  • Index(es):
    • Date
    • Thread