Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
- Subject: Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
- From: Ray <email@hidden>
- Date: Tue, 27 Mar 2012 17:31:35 +0200
On Mar 27, 2012, at 4:50 PM, Andreas Mayer wrote:
> The documentation for UIImage -scale says:
>
> "If you load an image from a file whose name includes the @2x modifier, the scale is set to 2.0. If the filename does not include the modifier but is in the PNG or JPEG format and has an associated DPI value, a corresponding scale factor is computed and reflected in this property. "
>
> So I would expect PNG images to retain their scale value when saved and loaded.
>
> If this does not work, there seems to be a bug somewhere.
> Ray, did you try to explicitly set the image's scale value before creating the PNG representation?
Well, I don't save it to a file, but to a NSData property on a Core Data managed object, and I use UIGraphicsBeginImageContextWithOptions, after which newImage = UIGraphicsGetImageFromCurrentImageContext() will set the scale of "newImage" appropriately (under retina to 2.0, I checked with setting a breakpoint and looking at the scale variable of the image)... It is more that the imageWithData class method on UIImage always will report a scale of 1.0 (is mentioned in this WWDC session I was talking about). Hmm...
_______________________________________________
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