• 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions


  • Subject: Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
  • From: David Duncan <email@hidden>
  • Date: Tue, 27 Mar 2012 10:31:44 -0700

On Mar 27, 2012, at 2:57 AM, Giacomo Tufano wrote:

> That's what I use to generate a thumbnail of sideSize side lenght in iOS3.x code.
> It uses iOS4+ functions for retina displays (I remember that you can assume iOS4+ with retina displays).
>
> CGSize newSize = CGSizeMake(sideSize, sideSize);
> #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
> 	if(UIGraphicsBeginImageContextWithOptions != NULL)
> 		UIGraphicsBeginImageContextWithOptions(newSize, NO, [[UIScreen mainScreen] scale]);
> 	else
> #endif
> 		UIGraphicsBeginImageContext(newSize);
> UIGraphicsBeginImageContext(newSize);
> [self drawInRect:CGRectMake(0, 0, sideSize, sideSize)];
> // Get the new image from the context
> UIImage *thumbnailImage = UIGraphicsGetImageFromCurrentImageContext();
> // End the context
> UIGraphicsEndImageContext();
>
> It works correctly on retina displays.
> To be honest I don't remember why I use that macro to test for iOS4, there were a reason and that was a workaround but cannot remember why. It works, anyway. :)


Your macro check is to attempt to remain compatible with the 3.2 or earlier SDK. It has served its purpose and can be retired :). If you no longer support iOS 3.x you can even remove the existence check for UIGraphicsBeginImageContextWithOptions.
--
David Duncan

_______________________________________________

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

References: 
 >Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions (From: Ray <email@hidden>)
 >Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions (From: Giacomo Tufano <email@hidden>)

  • Prev by Date: Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
  • Next by Date: Re: File types...
  • Previous by thread: Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
  • Next by thread: Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
  • Index(es):
    • Date
    • Thread