I am trying to resise a Bitmap image using bitmap.scaleInto function. I got the out of memory exception while trying to do that for an image having a 2MB size. How can I make a resize of large image files without getting such an exception?
Thanks
This can be closed, solution is here: http://supportforums.blackberry.com/t5/Java-Development/Beginner-OutOfMemory-Error-when-Resizing-Bitmap/m-p/706427/highlight/true#M137817
Related
I'm making an app using Swift in Xcode. I have a few buttons and images on one of my View Controllers. I am using high resolution images, but I noticed that they pixelate to the point where it is visible to the naked eye. There are some questions that I have found pertaining to the resizing of images, but none regarding immediate pixelization. I was hoping someone could help. Below are two images. The first is an image (a screenshot) from my app and the second is an image (also a screenshot) from another app that is not mine. The icon on the other app is smaller, but despite this is less pixelated.
have you tried using svg instead of jpg (lossy) or png(lossless)? It would seem that this would be the way to go, since you can expand to perfect definition on all resizing screens. svg uses code instead of an image format that can be lossy and given the examples you have posted would solve your issue.
you can use paint code for more easy worked , with paint code you can export svg
I figured it out. I just had to increase the dpi
I'm building a camera application that saves the image data to a single JPEG file in the sandbox. The images average at about 2mb in size.
Problem : I cannot display the images in a photo viewer because having a few images in memory throws memory warnings and makes scrolling through the images very slow.
I cannot split the image into tiles and save them to disk because that's even more expensive than displaying the single image. I tried splitting the image up into tiles upon capture, but on the 5S it took, on average, 5 1/2 seconds to save all the tiles to disk. It will only get worse from there as the app is executed on older devices. This is very bad because what if the user exists the app in the middle of the save? I will have missing tiles and no uncompressed original file to find missing tiles later.
Question : what's the best way to show a full sized image without causing memory issues and keeping the scrolling fast? Tons of camera applications on the App Store do this and the Photos app does this, there has to be a good solution.
Note : I'm currently showing a thumbnail of the image and then loading the full size image from disk in another thread. Once the full size image loading has finished, I present the full size image on the main thread. This removes the memory issues because I only have one full size image in memory at once, with two thumbnails, but still causes lagging on the scrollview because drawing the full size image in the main thread is still pretty expensive.
I would greatly appreciate any input!
you could..
create a down sized thumb nail..
create a smaller image and save that in a different "sandbox" folder.. and read that for browsing.. then after that load the image if the user wants to look at it full size.
One way to deal with this is to tile the image.
You can save the large decompressed image to "disk" as a series of tiles, and as the user pans around pull out only the tiles you need to actually display. You only ever need 1 tile in memory at a time because you draw it to the screen, then throw it out and load the next tile. (You'll probably want to cache the visible tiles in memory, but that's an implementation detail. Even having the whole image as tiles may relieve memory pressure as you don't need one large contiguous block.)
This is how applications like Photoshop deal with this situation.
Second way which I suggest you is to
check the example from Apple for processing large images called PhotoScroller. The images have already been tiled. If you need an example of tiling an image in Cocoa check out cimgf.com
Hope this will helps you.
I have an array of 24 high quality images. I am trying to animate them using uiimageView.animationImages property. But the app is crashing whenever I try to run this animation. I have searched a lot on this and found that the crashing is due to the number of high resolution images I am trying to animate. But I am not able find any alternative for this. I tried using animated gif images but the quality is too bad. Please help.
You could try to create your own UIImageView class with an NSArray of all images. Load all UIImages, start a NSTimer and cycle through all UIImages. This might not be the most efficient way but it shouldn't crash.
Although the images are high resolution and big, your screen size is small. So I would say scale down the images to you max screen size and then try using animationImage property of UIImageView.
That way you save on memory and load time.
I have a big picture to show in UIScrollView.It's 28.1 MB.And it often crash the app.Is there some methods to deal with it so that app won't crash?
Here you go buddy,
Convert Large Image to tiles
Displaying tiled images in UIScrollview
Tiled Images in UIScrollView
If it's a static PNG image, run it through ImageAlpha and ImageOptim (Google these). You might be able to get it down by well over 50%. Bundle the resulting image with your app instead.
Note that ImageOptim is lossless whereas ImageAlpha is lossy. You can use them in conjunction.
Split up the image and load the pieces only when necessary.
Problem:
I've got a PyQt4 GUI application which has to import 16-bit grayscale image data and do some calculations on the image. The Gui has some control elements and a QTabWidget() element with two tabs, where one displays the image and the other represents the calculation results in a table. The image representation is done using Matplotlib.
In my applications I should be able to open images of up to 10000x12500 pixels which corresponds to 250MB of image data. Unfotunately, with my application I am only able to open images of about the size of 130MB. When importing and displaying data bigger than 8000x8000 pixels, my application stops showing Memory Error. Although the image itself is 128MB of size, the windows task manager shows 694MB of used memory for the python task. Images of the size 8000x9000 pixels can't be displayed any more.
My computer has 4GB of RAM memory. I don't think that the problem occurs due to insuffiecient memory.
Question:
How can I enable my application to display images of sizes up to 10000x12500 pixels grayscale 16-bit? Is there a Matplotlib internal limitation I can modify?
I searched the net but didn't find any answer. The closest problem description to the one I have can be seen in Excessive memory usage in Matplotlib imshow. But changing the display command from show() to draw() didn't help.
Thank you VERY MUCH for any help.
mapplotlib is not efficient with memory with images, there are multiple internal copies of the data.
Unless you have a gargantuan screen (at 300ppi, your image is 33in x 42in), your images are going to be down-sampled when they are displayed. I would suggest down-sampling your images to a size that is closer to the pixel count of the area it will actually be. You probably will want to write something do to adaptive down sampling based on what the user can actually see.
related question and answer