Note that there are some explanatory texts on larger screens.

plurals
  1. POUIImageJPEGRepresentation giving 2x images on retina display
    primarykey
    data
    text
    <p>I have this code, which creates an image, and then adds some effects to it and sizes it down to make <code>largeThumbnail</code>.</p> <pre><code>UIImage *originalImage = [UIImage imageWithData:self.originalImage]; thumbnail = createLargeThumbnailFromImage(originalImage); NSLog(@"thumbnail: %f", thumbnail.size.height); NSData *thumbnailData = UIImageJPEGRepresentation(thumbnail, 1.0); </code></pre> <p>Later on:</p> <pre><code>UIImage *image = [UIImage imageWithData:self.largeThumbnail]; NSLog(@"thumbnail 2: %f", image.size.height); </code></pre> <p>NSLog returns:</p> <pre><code>thumbnail: 289.000000 thumbnail 2: 578.000000 </code></pre> <p>As you can see, when it converts the image back from data, it makes it 2x the size. Any ideas why this may be happening?</p> <p>Large thumbnail code:</p> <pre><code>UIImage *createLargeThumbnailFromImage(UIImage *image) { UIImage *resizedImage; resizedImage = [image imageScaledToFitSize:LARGE_THUMBNAIL_SIZE]; CGRect largeThumbnailRect = CGRectMake(0, 0, resizedImage.size.width, resizedImage.size.height); UIGraphicsBeginImageContextWithOptions(resizedImage.size, NO, 0); CGContextRef context = UIGraphicsGetCurrentContext(); //Image CGContextTranslateCTM(context, 0, resizedImage.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextDrawImage(context, largeThumbnailRect, resizedImage.CGImage); //Border CGContextSaveGState(context); CGRect innerRect = rectForRectWithInset(largeThumbnailRect, 1.5); CGMutablePathRef borderPath = createRoundedRectForRect(innerRect, 0); CGContextSetStrokeColorWithColor(context, [[UIColor whiteColor] CGColor]); CGContextSetLineWidth(context, 3); CGContextAddPath(context, borderPath); CGContextStrokePath(context); CGContextRestoreGState(context); UIImage *thumbnail = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return thumbnail; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload