• 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
Re: Antialising a CGImageRef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Antialising a CGImageRef


  • Subject: Re: Antialising a CGImageRef
  • From: Chris Meyer <email@hidden>
  • Date: Thu, 20 Feb 2003 10:55:10 -0800

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.

  • Follow-Ups:
    • [SOLVED]Re: Antialising a CGImageRef
      • From: Tito Ciuro <email@hidden>
References: 
 >Antialising a CGImageRef (From: Tito Ciuro <email@hidden>)

  • Prev by Date: Re: omitting zero-test
  • Next by Date: [SOLVED]Re: Antialising a CGImageRef
  • Previous by thread: Re: Antialising a CGImageRef
  • Next by thread: [SOLVED]Re: Antialising a CGImageRef
  • Index(es):
    • Date
    • Thread