Android 图片压缩没有完全载入内存
Android picture compression without loading fully into memory
有什么方法可以在不将图像完全加载到内存的情况下压缩图像?
据我了解 BitmapFactory.decodeStream
和类似的方法将所有内容加载到内存中,只有在加载整张图片后才能通过 Bitmap.compress
进行压缩
我的任务是将图片从 android 发送到服务器
您可以使用BitmapRegionDecoder只读取原始图像的一部分,然后分别压缩和上传每个部分。
BitmapRegionDecoder can be used to decode a rectangle region from an image. BitmapRegionDecoder is particularly useful when an original image is large and you only need parts of the image.
To create a BitmapRegionDecoder, call newInstance(...). Given a
BitmapRegionDecoder, users can call decodeRegion() repeatedly to get a
decoded Bitmap of the specified region.
有什么方法可以在不将图像完全加载到内存的情况下压缩图像?
据我了解 BitmapFactory.decodeStream
和类似的方法将所有内容加载到内存中,只有在加载整张图片后才能通过 Bitmap.compress
我的任务是将图片从 android 发送到服务器
您可以使用BitmapRegionDecoder只读取原始图像的一部分,然后分别压缩和上传每个部分。
BitmapRegionDecoder can be used to decode a rectangle region from an image. BitmapRegionDecoder is particularly useful when an original image is large and you only need parts of the image.
To create a BitmapRegionDecoder, call newInstance(...). Given a BitmapRegionDecoder, users can call decodeRegion() repeatedly to get a decoded Bitmap of the specified region.