Help required to attain the actual image size - iphone

Saving images to a given location
i followed the above link and it works but i dont get actual image size...it is much bigger...
how can i fix it...
Thanks for any help

How do you mean - bigger?
The screen is 320x480 pixels. So if you the view you're saving is the whole screen, that's what you'll get.
Depending on your (computer) screen resolution, this may look quite big or quite small, and will almost certainly look different than the actual size of the iphone screen.

Related

Performance problem about showing images

My problem is i have 50 images each is 157X157 pixels and take 25kb.They are connected to a slider and when the user slides the slider they change 0 to 100. It works but my problem is iphone 3g and 3gs is very slow its hard to see the images and sometimes it stuck for a second to show the next image. I use UIImageview to show the images.How can i do it better so the phone that before retina display can show them without stucking? Thanks for answers and your time.
edit: All pictures is in the file they are not taking from url.
Preload them when your app launches. Sending each of them a -size message should be enough to force them to load.
Maybe you can preload a lowRez version of your pictures ( like 78px )
when the slider move, you display the lowRez, and when it's stop, you swap to original picture.
convert them to the size they will be drawn at (don't rescale them on the fly).
ps: a sample would help a lot

iphone best practice, how to load multiple high quality images

I have about 20-ish high quality images (~3840x5800 px) that I need to load in a simple gallery type app. The user clicks a button and the next image is loaded into the UIImageView.
I currently use [UIImage imageWithContentsOfFile:] which takes about 6 seconds to load each image in the simulator :(
if I use [UIImage imageNamed:] it takes even longer to load but caches the images which means its quicker if the user wishes to see the same images again. But it may cause memory problems later with all that caching crashing my app.
I want to know whats the best practice for loading these? I'm experimenting with reducing image file size as much as is possible but I really need them to be high quality image for the purpose of the app (zoomable, etc.).
Thanks for any advice
[EDIT]
Hey again guys,
Thanks for all ye're advice. The project's spec's have changed a little. Now as well as displaying the images they firstly have to be zoomed in to a particular spot and when the user taps next it zooms out and then displays the next image. So I'm not sure if the proposed solutions fits?
Apple's docs recommend against trying to load single images that are larger than 1024x1024. You should look into using CATiledLayer instead, to load pieces of the images as needed.
You can have a look at this Apple sample:
http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010080
It shows how to load big images, breaking them in tiles for different zoom levels.
You can't see all those pixels at any given time, so there is no need to load them all. Load lower-res copies ("big-thumbnails") to view the complete image, then selected sub-tiles, maybe of 2 or more different resolution sets, after the user zooms in.
The CATiledLayer API may be able to handle some of the latter for you.

Loading a 20MB png in a UIImageView embedded in a UIScrollView

I have a large png Image that I need to Zoom&Move.
I therefore created a UIScrollView and embedded a UIImageView.
The App works fine in the simulator, but when running it on the device (8GB iPod Touch) it crashes as soon as the view is loaded.
I tried with a smaller test Image (4MB) works fine and suspect the iPod can't handle a 20MB PNG. I also tried different other formats, such as JPG (in various save patterns), but that did't help either.
Any clues how I can solve this?
Ouch, 20M is a large image. The first thought that comes to mind is can you dice up the image? I.e. instead of one image have a whole bunch of small images which together make up the larger image. Then you can load on demand the same way google maps downloads image squares.
have a look at the ScrollViewSuite Example from apple. Sounds exactly like what you are trying to do.
3_Tiling demonstrates:
How to subclass UIScrollView to add content tiling
Reusing tiles to optimize performance and memory use
Changing the resolution of the content in response to zooming
I suggest the Example Photoscroller. It demonstrates CATiledLayer which you can use to tile your image and even use smaller images as lod images. It's much smaller then the complete ScrollViewSuite example but has everything you need to do what you want. It contains only 2 classes which you should be able to use in your project with minor edits.
You might want to check the WWDC 2010 Session #104 "Desinging Apps with Scroll Views"... they handle and explain that example.
You will need to tile your image. I suggest imagemagick for that :)

iPhone 4 resolution difficulty - #2x naming technique not working for button image

I have a button with an image set through interface builder. The original image is SearchImage.png and the high rez version is SearchImage#2x.png. I'm absolutely sure that no typos were made, and the higher resolution image is indeed exactly twice the size (ie twice as tall, twice as wide) as the lower resolution image, yet the office's iPhone4 still only loads the low resolution image.
Does anyone have any ideas what the problem might be?
I have read all the relevant Apple documentation.
Thanks!
Tristan
Just assign the image property "SearchImage.png" and include both SearchImage.png and SearchImage#2x.png in your main bundle and it will load the correct image.
See https://devforums.apple.com/message/233916#233916.

PNGs and UIImage Optimisation

Is it better to have a PNG, say 320px x 44px and display it once, or to have a PNG that is 320px x 4px and use [UIColor colorWithPatternImage:]?
I know that the iPhone handles PNGs well and decompresses them, so in terms of memory, would it be best to use the smallest possible images, and in this case, use the UIColor method to repeat it?
Are there any drawbacks to using colorWithPatternImage? Perhaps over larger areas, maybe half a screen size or full screen sized?
Many thanks,
Michael
I'm willing to bet that choosing one over the other won't make a noticeable difference in your app's responsiveness. The only place people might notice a difference is if they're downloading your app over EDGE, in which case the tiled image is the way to go.
I would do whatever makes your app most maintainable.
The answer depends on what "better" means to you. If you're more concerned about the size of the app, then smaller pictures would help you. If the application's speed is more of an issue than size, then a larger image will eliminate the need for all the colorWithPatternImage calls and effectively run faster.