我不知道是不是可以旋转存储在SD卡的图像,而无需加载它的内存。
I am wondering is it possible to rotate an image stored on sdcard without loading it's to memory.
原因是为什么我找的就是著名的OutOfMemoryError。我知道我可以通过下采样大的图像避免,但其实我并不想以减少图像的尺寸,我想有原来的形象,但在旋转90度。
The reason is why I am looking for that is famous OutOfMemoryError. I know I can avoid it by downsampling large image but in fact I don't want to reduce size of that image, I want to have original image but rotated on 90 degrees.
有关热烈AP preciated任何建议:)
Any suggestions about that are warmly appreciated :)
你应该去c。使用 Bitmap`的图片code德$ C $。您应该遵循加载如何做到这一点psented由谷歌大图片 $ P $。它帮助了我很多,你会发现在内存占用较大的差异。
you should decode decode the Images using
Bitmap`. you should follow Loading Large Image presented by google on how to do it.. it helped me alot, you'll notice the large difference in the RAM usage..
更新如果你想要的是只需旋转您可以使用此code图像
UPDATE if all you want is just rotate the image you can use this code
Matrix matrix = new Matrix();
matrix.setRotate(90);
result = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),bitmap.getHeight(), matrix, false);
如果你只需要设置图像方向(例如照片显示方向它拍摄的时候),可以使用
if you just need to set the image orientation (for example the photo orientation when it's was taken) you can use
ExifInterface exif = new ExifInterface(filePath);
与属性 ExifInterface.TAG_ORIENTATION
我希望这可以帮助你。
with the attribute ExifInterface.TAG_ORIENTATION
I hope this helps you
上一篇:IntelliJ IDEA的不生成ID在R.javaIDEA、IntelliJ、java、ID
下一篇:什么时候需要使用singleTop launchMode在Android窗口小部件或应用程序?什么时候、部件、应用程序、窗口