Utility class that deals with operations with an ImageView. refer to class #com.android.bitmap.util.BitmapUtils and # com.cloudream.ishow.util.gallery3d.common.BitmapUtils
| 46 | * {@link com.cloudream.ishow.util.gallery3d.common.BitmapUtils} |
| 47 | */ |
| 48 | public final class BitmapUtils |
| 49 | { |
| 50 | |
| 51 | static final Rect EMPTY_RECT = new Rect(); |
| 52 | |
| 53 | static final RectF EMPTY_RECT_F = new RectF(); |
| 54 | |
| 55 | /** |
| 56 | * Reusable rectangle for general internal usage |
| 57 | */ |
| 58 | static final RectF RECT = new RectF(); |
| 59 | |
| 60 | /** |
| 61 | * Used to know the max texture size allowed to be rendered |
| 62 | */ |
| 63 | static int mMaxTextureSize; |
| 64 | |
| 65 | /** |
| 66 | * used to save bitmaps during state save and restore so not to reload them. |
| 67 | */ |
| 68 | static Pair<String, WeakReference<Bitmap>> mStateBitmap; |
| 69 | |
| 70 | public static final BitmapFactory.Options OPTION_RGBA_8888 = new BitmapFactory.Options(); |
| 71 | { |
| 72 | // Android's Bitmap.Config.ARGB_8888 is misleading, its memory layout is RGBA, as shown in |
| 73 | // JNI's macro ANDROID_BITMAP_FORMAT_RGBA_8888, and getPixel() returns ARGB format. |
| 74 | OPTION_RGBA_8888.inPreferredConfig = Bitmap.Config.ARGB_8888; |
| 75 | OPTION_RGBA_8888.inDither = false; |
| 76 | OPTION_RGBA_8888.inMutable = true; |
| 77 | OPTION_RGBA_8888.inPremultiplied = false; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Rotate the given image by reading the EXIF value of the image (URI).<br> |
| 82 | * If no rotation is required the image will not be rotated.<br> |
| 83 | * New bitmap is created and the old one is recycled. |
| 84 | */ |
| 85 | public static RotateBitmapResult rotateBitmapByExif(Bitmap bitmap, Context context, Uri uri) |
| 86 | { |
| 87 | try |
| 88 | { |
| 89 | File file = getFileFromUri(context, uri); |
| 90 | if(file.exists()) |
| 91 | { |
| 92 | ExifInterface ei = new ExifInterface(file.getAbsolutePath()); |
| 93 | return rotateBitmapByExif(bitmap, ei); |
| 94 | } |
| 95 | } |
| 96 | catch(Exception ignored) |
| 97 | { |
| 98 | } |
| 99 | return new RotateBitmapResult(bitmap, 0); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Rotate the given image by given Exif value.<br> |
| 104 | * If no rotation is required the image will not be rotated.<br> |
| 105 | * New bitmap is created and the old one is recycled. |
nothing calls this directly
no outgoing calls
no test coverage detected