Skip to content

Conversation

@AliSoftware
Copy link
Owner

That's actually probably what we want.

For example imagine an screenshot taken from a retina iPhone (Power+Home), saved in the Camera Roll, then transferred via email or whatnot to a non-retina iPhone.
The UIImage's scale will then be 2.0 even when opened from the non-retina iPhone, and if that non-retina iPhone wants to resize the original image, we should not downscale its resolution/scale to 1.0 just because this retina image is opened on a non-retina device.

The UIImage you resize may even never be displayed on the screen, e.g. imagine a retina image downloaded from the web, resized with my code on a non-retina iPhone, then sent back to a WebService without even being displayed on that non-retina iPhone, just being manipulated via code…

That's the reason why I used the image's scale instead of the device scale, because we manipulate the image itself, independently of the device the code is executing on.

@faceleg
Copy link
Author

faceleg commented Mar 12, 2015

I understand what you mean, but in my case - downscaling album art images to display in "bottom" mode inside a UIImageView, I do want it to use the device's scaling...

Could we add another method with "useDeviceScaling:YES/NO"?

@AliSoftware
Copy link
Owner

That would be a better option, yes. 👍

What I would recommend for the new API:

  • Move the code to a new method named -(UIImage*)resizedImageToSize:(CGSize)dstSize forceScale:(CGFloat)scale and use the scale parameter instead of self.scale in the code;
  • Keep -(UIImage*)resizedImageToSize:(CGSize)dstSize but as a convenience method that simply calls this new designated -resizedImageToSize:forceScale: method using self.scale for its second parameter. That way this method will still exist and still work the same as before;
  • Update the documentation in the header (especially to answer the question that if we use dstSize={50,50} and forceScale=2.0 on a non-retina iPhone, will it lead to an image of size 50x50 points or 50x50 pixels or 100x100 points etc. to clarify such uses)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants