开发者

Android: is it possible to paint a large image without resampling?

开发者 https://www.devze.com 2023-03-05 23:37 出处:网络
I would like to read images from InputStreams, and draw them to my canvas.Unfortunately, the images may be very l开发者_StackOverflowarge, and could easily cause out of memory exceptions.BitmapFactory

I would like to read images from InputStreams, and draw them to my canvas. Unfortunately, the images may be very l开发者_StackOverflowarge, and could easily cause out of memory exceptions. BitmapFactory allows me to provide a sample size value, which will down sample the image as it is processed and avoid the memory issues. However, image quality suffers.

Ideally, canvas would provide a paint image method which can paint from an InputStream, as opposed to from a Bitmap, but I haven't found anything of this type. Does this exist, or is there any other way to safely render arbitrarily large images from InputStreams without down sampling?


I am not sure what image format you are using but if you want to send a lossless image (or with less loss than has already occurred), It can't be compressed better than JPEG. so, use JPEG first.

Here is an example for drawing image on Canvas. Override the 'draw' method. http://www.androidsnippets.com/drawing-an-image-as-a-map-overlay2

At the end, hacking it

Probably, pre-splitting the image; compressing each individual one and restoring at the end sounds logical.

Here are few attempts,

http://kalanir.blogspot.com/2010/02/how-to-split-image-into-chunks-java.html

And

http://www.anddev.org/multimedia-problems-f28/chunk-of-a-big-big-image-t6211.html


The answer appears to be: no, there isn't.

0

精彩评论

暂无评论...
验证码 换一张
取 消