Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-29 Thread David Duncan
On Mar 29, 2012, at 1:50 AM, Ray wrote: > David, am I correct if I pass 0 for the scale in > +imageWithCGImage:scale:orientation: it will generate a UIImage with a scale > of 1? (It seems to do that, which in my case is just what I need ;) I would recommend being explicit and checking for 0 yo

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-29 Thread Ray
On Mar 27, 2012, at 7:29 PM, David Duncan wrote: > Simplest solution is to save the scale along side the image itself (under the > assumption that this data can possibly end up on a non-retina device for some > reason) or to create a new UIImage with the screen scale via > +imageWIthCGImage:sc

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-28 Thread Ray
a-dev@deployedsmarts. > com > Datum: 27.03.2012 19:27 > An: "Andreas Mayer" > Kopie: > Betreff: Re: > Question about UIImage, scaling, and > UIGraphicsBeginImageContextWithOptions > > Andreas: > > On Mar 27, 2012, at 6:41 PM, > Andreas Mayer

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-28 Thread Ray
On Mar 27, 2012, at 7:29 PM, David Duncan wrote: > Simplest solution is to save the scale along side the image itself (under the > assumption that this data can possibly end up on a non-retina device for some > reason) or to create a new UIImage with the screen scale via > +imageWIthCGImage:sc

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 1:04 PM, Andreas Mayer wrote: > > Am 27.03.2012 um 20:13 schrieb David Duncan: > >> Primarily because people abuse the resolution field, and as such it cannot >> be trusted for this particular function. In a perfect world, we would only >> ever see 72 (1x) or 144 (2x) in th

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 20:13 schrieb David Duncan: > Primarily because people abuse the resolution field, and as such it cannot be > trusted for this particular function. In a perfect world, we would only ever > see 72 (1x) or 144 (2x) in the resolution field, but instead the value tends > to be pra

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 10:59 AM, Andreas Mayer wrote: > > Am 27.03.2012 um 19:29 schrieb David Duncan: > >> Simplest solution is to save the scale along side the image itself > > That's what I just implemented. But I still think PNG images should retain > the scale factor. Why saving that inform

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 19:29 schrieb David Duncan: > Simplest solution is to save the scale along side the image itself That's what I just implemented. But I still think PNG images should retain the scale factor. Why saving that information elsewhere when the format explicitly supports this? Andr

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 19:19 schrieb Ray: > Edit: I just checked and they say they do this for compatibility reasons. > It's around the 9'40'' mark, session 134 - Optimize your iPhone App for the > Retina Display (WWDC 2010, I assume you have access)... I'll check this out, thanks. Andreas ___

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
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, sideSiz

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 12:38 AM, Ray wrote: > Now, when I generate a new image on an iPhone with a retina screen, in which > case the above UIGraphicsBeginImageContextWithOptions uses a scale of 2.0, > the image in the table view shows too big. This is because [UIImage > imageWithData:item.listIma

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Andreas: On Mar 27, 2012, at 6:41 PM, Andreas Mayer wrote: > So either imageWithData does not restore the scale from PNG data or > UIImagePNGRepresentation() does not store it in the first place. When I set a breakpoint at UIImagePNGRepresentation(newImage) I can see that the scale of newImage

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Andreas: On Mar 27, 2012, at 6:41 PM, Andreas Mayer wrote: > The scale value is the same as set in > UIGraphicsBeginImageContextWithOptions(), as far as I can tell. Right, that was what I meant actually. > But it will be lost when creating PNG data and reading it again. (Since I > don't see

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 17:31 schrieb Ray: >> 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? >

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
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 asso

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Right, cell.imageView sets its own frame, no matter where you try to set it manually. I could of course add my own image view to the cell's contentView... On Mar 27, 2012, at 4:21 PM, Roland King wrote: > UIImageView's scale automatically so just setting the frame of the > UIImageView containin

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer
Am 27.03.2012 um 13:47 schrieb Marco Tabini: > When you save to a file format that supports metadata, like JPEG, some of the > metadata is stored there, while other is derived from the file name. So, for > example, if you were to save a PNG file to disk with an @2x suffix, upon > loading it wi

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Roland King
UIImageView's scale automatically so just setting the frame of the UIImageView containing the UIImage to ( x, y, 44, 44 ), possibly after you load the image into it, will just work whatever size the image actually is on whatever type of display you are using. On Mar 27, 2012, at 3:38 PM, Ray

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Hi Marco, Thanks for your thoughts! Let me first say, the original app is already out there, using the old UIGraphicsBeginImageContext (at the time there was no UIGraphicsBeginImageContextWithOptions to begin with), used now on a variety of devices with normal and retina screens etc. The probl

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Marco Tabini
Hi Ray— > But this seems kludgy and it's using programmer's knowledge, so to speak. I > watched WWDC2010 session 134 "Optimize your iPhone App for the Retina > Display" again, searched stackoverflow etc. but I can't find a more elegant > solution. What would be a more thorough approach? Maybe i

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Thanks Giacomo for your answer, but the problem is not so much that the resizing doesn't work, but that [UIImage imageWithData:listImage] always returns a scale of 1.0 for the image. This means that I encounter the problem described, when images are saved using an iPhone with a retina screen...

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Giacomo Tufano
Il giorno 27/mar/2012, alle ore 09:38, Ray ha scritto: > OK, so I have this iOS 3.x code base that I need to update. I have the > following code, to make a thumbnail image: > Code is simplified, just for illustrative purposes. I store imageData as a > binary property (called "listImage") in a Co

Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
OK, so I have this iOS 3.x code base that I need to update. I have the following code, to make a thumbnail image: ... // let's say we have a UIImage *selectedImage with a size of 1000 x 1000 UIImage *newImage; NSData *imageData; UIGraphicsBeginImageContext(CGSizeMake(44.0, 44.0)); [selectedImage