No matter what I do, I can\'t seem to figure out why my images keep coming out fuzzy on iOS displays. It doesn\'t matter whether it\'s one I created in an image editor or dr
UIGraphicsBeginImageContext
:
... is equivalent to calling the
UIGraphicsBeginImageContextWithOptions
function with the opaque parameter set toNO
and a scale factor of1.0
.
However, UIGraphicsBeginImageContextWithOptions
defines its scale
parameter as:
scale
The scale factor to apply to the bitmap. If you specify a value of0.0
, the scale factor is set to the scale factor of the device’s main screen.
So your use of UIGraphicsBeginImageContextWithOptions
is creating a context with a scale of 1.0
. That's correct for e.g. last year's iPad Mini but all retina-class devices have a 'native' scale of 2.0
— two pixels per logical point. UIGraphicsBeginImageContextWithOptions
introduced the special case of 0.0
so that you don't have to mess about dealing with getting the correct number for that device for yourself (though [[UIScreen mainScreen] scale]
would be an easy way).
So switch your exiting call to UIGraphicsBeginImageContext(CGSizeMake(1000, 1000))
to:
UIGraphicsBeginImageContextWithOptions(CGSizeMake(1000, 1000), NO, 0.0)
Otherwise the context you create will have a quarter as many pixels as the screen does in the corresponding amount of space.