store bitmaps in an array? - java

Hi I am trying to download some images from the server, and I won't save them to the SD card because I want them to be gone when the application finishes. Therefore I want to store them in an array of bitmaps. Is this feasible? My largest image would be about 1000X1086 and there would be about 30-40 of them.

No. A bitmap is stored in memory as uncompressed bytes. A 1000x1086 full color bitmap is about 4MB. Most phones allow an app to use 16-40 MB max, and that includes built in resources. You're over by a factor of 10.

I'm using Universal Image Loader. You can save the images only in memory and clear it when you exit.
Here are all options for download images.
https://github.com/nostra13/Android-Universal-Image-Loader

You have an option... which ain't built in phone memory dependent...
You can save the images in the memory card and delete when the app finishes itself...
This is a really elegant method...

Related

Load only some images from disk cache using Universal Image Loader

I am using the Universal Image Loader disk cache feature. I have restricted it to only cache images with the a maximum of 480x320 resolution. This works nicely, but when I tap those images to open the full size images, UIL loads the image from the disk cache and I see a stretched / distorted version of the small cached image.
I want to know how to tell UIL to load the images from disk cache but only for specific images. I have tried searching without luck.
Thanks.
It seems that the only answer to this is to create two instances of the ImageLoader. One with disk caching and one without it.

Android - Optimizing application performance by image compression

I am working on an application that are loaded with large png images.
I started to optimize the app performance by reducing the size of each image to it's original size in phone.
I am using adobe photoshop . I was wondered how would be better to output the image file ? save it like normal or use "save for web" and compress it to PNG-8 or PNG-24 .
what do you advice ?
Try to use some of compress tools like http://tinypng.com or http://compressor.io, android studio has bundled some image optimization, if you want to know more watch Google I/O session about it.
http://youtu.be/r_LpCi6DQME

Base64 Image Size variation while saving

I am creating one application which downloads the images in base64 string format and save it in an image file while downloading data.
My application is available on two platforms: iOS/Android and PC/Mac
The problem is when I downloading the images and saving those on disk I am getting a size difference. In mobile it is downloading the exact size which I have uploaded but on my mac its size is greater than the actual size. Why the size of image in mac is greater than that of actual size downloaded?
in some of operating system maybe file size were difference, and its not problem if, for example your images view correctly.
I have observed that if I use
ByteArrayInputStream and Bufferred Image and ImageIO
class then it is saving the image in high resolution. Now I am using the class
FileOutputStream
to write the content in file. Its keeping the size same as uploaded.

Which is Faster regarding Android Images IO

Which is faster, to recieve images as JPG from server, and save it, then show it in a ListView or what ever
OR
receive images in an XML (as encoded String) from server, then decode it, then show it in a ListView (or even save it then show it from memory)
what is the best way (regarding performance) in transfering images FROM a server TO an android device
thanks in advance
That depends on where the limitation is. If the bandwidth of your connection is very small try to transfer as few bytes as possible. However, high compression usually costs more CPU, so if CPU power is limiting you it may be better to use a lower compression.
I am not sure what you mean by "receive images in an XML". Is it some vector format like SVG? That would normally be much smaller than a raster image (especially for large sizes).
To sum up, you will need to do some experiments to find out what works best in your case.
The best way is to get the image URL from the server and then download the image using some image managing library like https://github.com/nostra13/Android-Universal-Image-Loader or google's volley. These kind of libraries highly configurable and taking care of all the aspects of managing a bitmap.

Java Image resizing (3 sizes) upload each to Amazon S3

I'm using grails with jetS3t to upload an image to S3, this works fine.
But now I need to re-size the image (thumbnail, small and medium) and upload them all to S3.
So far I'm thinking about using ImageMagick, But don't know which is the best way to approach the resizing.
Should I:
Upload original to S3,
then re-size using the URL received from S3(another download), and upload the re-sized image to S3, (x3)
OR
Upload and use image bytes in memory, do all the resizing, upload the 3 re-sized photos and the original to S3
Depends on your quality requirements and memory availability.
If you want the resized images to be good quality then using ImageMagick is probably a good option but that requires the source image to be saved locally on disk. On the other hand, you won't need to store all images in memory. Im4Java worked very well for me as an interface to IM.
Using the Java Graphics package and BufferedImage class you can do an in-memory operation but this might not produce as good quality images.

Categories

Resources