ios - Why PNG image got double size after taking screenshot of UIView? -


i able take screenshot uiview @ iphone 6 below code: -

here have printed 2 logs. first gives me image size {375, 667} after converting png format gives me image size {750, 1334}.

i know it's converting retina display. each point represented 2 pixels on screen saved image double resolution.

but need image size {375, 667} png format.

- (uiimage *)imagewithview:(uiview *)view {     uigraphicsbeginimagecontextwithoptions(view.bounds.size, no, [uiscreen mainscreen].scale);     [view drawviewhierarchyinrect:view.bounds afterscreenupdates:yes];     uiimage *image = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();      nslog(@"image size: %@", image);  // image size: <uiimage: 0x1700880c0>, {375, 667}      nsdata* imagedata =  uiimagepngrepresentation(image);     uiimage* pngimage = [uiimage imagewithdata:imagedata];     uiimagewritetosavedphotosalbum(pngimage, nil, nil, nil);      nslog(@"png image size: %@", pngimage);  // png image size: <uiimage: 0x174087760>, {750, 1334}      return image; } 


big image:- enter image description here

small image:-

enter image description here

just not bad quality can create image screen scale

but when load can use this

cgfloat screenscale = [uiscreen mainscreen].scale; if (screenscale != img.scale) {     img = [uiimage imagewithcgimage:img.cgimage scale:screenscale    orientation:img.imageorientation]; } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -