what's biggest size image can UIWebview handle?
the origin image size is: width 700 pixels, height 6900 pixels, And uiwebview display nothing.
iOS has the 3MB size limitation. the image size (width x height) must less than 3 * 1024*1024
I've discovered from some testing a limit on my html5 canvasses of 768*4096, or 3MB at 1 byte per pixel. The same resolution is enforced for images, as its not the original image size that matters, but the size of the bitmap that is rendered on the screen..
Related
I want to use srcset to provide 2x images for iPhone and iPad, but the 2x descriptor applies to both and the images should be different.
On both devices the image is full width. But on iPhone 2x of 320w is 640w and on iPad Pro 2x of 1024 is 2048w.
How could I differentiate between the two?
The x descriptor is more suited to images which width is fixed across viewports.
For variable width images, you should use the w descriptor.
For example:
<img
src="image320.jpg"
srcset="image320.jpg 320w, image640.jpg 640w, image960.jpg 960vw, image1280.jpg 1280vw, image1600.jpg 1600vw, image1920.jpg 1920vw, image2240.jpg 2240vw, image2560.jpg 2560vw"
sizes="100vw">
The w descriptor applies the screen density factor to the CSS width of the image to get the actual image width to download.
The image1920.jpg image will be downloaded by the browser for several configurations:
screen density 1 with viewport width equal to or below 1920px
screen density 2 with viewport width equal to or below 960px
screen density 3 with viewport width equal to or below 640px
etc.
I have some image I got from the web. Let's say that the max size I can make it without pix elating is 500 x 500. So with that said, should I make the #2x version of it, simply the 500 x 500 version, and regular version (ie for non retina) 250 x 250? Just a little confused about sizing the image correctly for the right screen resolution and any help would be appreciated.
Yes what you said is correct.
Keep in mind though that once you put it on the device the #2x will display as 250x250 pts on a retina screen.
If the #2x version is 500 x 500 then it will be treated at load time as a 250 x 250 double-resolution image (scale = 2).
The Picture taken from the iphone cam is nearly 2.5 Mb, How to reduce this size ,I have tried
UIJPEGRepresentation(image,0.1f),but it does not effect the size ?
You really can't reduce the size the images takes up in memory.
When an image is loaded, basically a UIImage object the size wil be width x height x 4 bytes. That is the size the an uncompressed image will take up in memory.
Since you can use compressed images all image, once loaded in a UIImage will be uncompressed.
If you really need so save some memory, save the image to disk and create a thumbnail which you use in your app. Then when need you can load the larger image and use it,
Try using the Resize method in UIImage+Resize.h
https://github.com/AliSoftware/UIImage-Resize
[aImgView setImage:[ImageObjectFromPicker resizedImageWithContentMode:UIViewContentModeScaleAspectFit bounds:YourSize interpolationQuality:kCGInterpolationHigh]];
I want to resize images, but it should keep the height/width ratio when doing the resizing. What I do is, first I check whether which side (width or height) is the long. If the width is long, I'll give 150 to the width's size and resize the height without affecting to the shape of the image and vise versa. I am talking this resized image for a edge detection algorithm and output binary image is sent to the neural network which requires constant number of inputs. In this case, one side of (width or height) the image is 150 and other side is less than 150(vary from image to image). But I want to add black color to the other side(less than 150) until its size is 150. So, I can sent 150*150 inputs to the neural network.
Question is How can I add black color to the other side(less than 150) until its size is 150?
Thanks in advance
http://www.mathworks.com/help/toolbox/images/ref/imresize.html
http://www.mathworks.com/help/toolbox/images/ref/padarray.html
newim = imresize(im, 150 / max(size(im));
paddedim = padarray(newim, size(newim) - 150, 0);
Creates an matrix of zeros. Calculate the position of the top-left pixel. Then copy your image to that matrix slicing from the top-left pixel.
guys.i'm new to iphone.i run the zoomingpdfview demo,everthing is fine,except that i don't want the pdf is zooming out smaller than the screen's size,or even very small..
i've tried many ways,but still can't.
so,how can i achieve that goal?thanks in advance.,any advice will be gratefull.
There's a property on a UIScrollView called minimumZoomScale. However, this isn't measured in pixels, it's measured as a factor of the size of the view.
You will need to calculate the min zoom yourself i.e.
// for a pdf width 230 and screen width 360 your min zoom would be 2.0
// a pdf width 720 and screen width 360 your min zoom would be 0.5
// So, to set the zoom for a scroll view
[myScrollView minimumZoomScale:screenWidth / pdfWidth];
However, you might have to calculate this for each visible page - pdfs can have pages of different size :)