|
|
@ -175,32 +175,38 @@ public class CameraUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Bitmap bitmap; |
|
|
|
Bitmap bitmap; |
|
|
|
if (maxWidth < Integer.MAX_VALUE || maxHeight < Integer.MAX_VALUE) { |
|
|
|
try { |
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options(); |
|
|
|
if (maxWidth < Integer.MAX_VALUE || maxHeight < Integer.MAX_VALUE) { |
|
|
|
options.inJustDecodeBounds = true; |
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options(); |
|
|
|
BitmapFactory.decodeByteArray(source, 0, source.length, options); |
|
|
|
options.inJustDecodeBounds = true; |
|
|
|
|
|
|
|
BitmapFactory.decodeByteArray(source, 0, source.length, options); |
|
|
|
int outHeight = options.outHeight; |
|
|
|
|
|
|
|
int outWidth = options.outWidth; |
|
|
|
int outHeight = options.outHeight; |
|
|
|
if (orientation % 180 != 0) { |
|
|
|
int outWidth = options.outWidth; |
|
|
|
outHeight = options.outWidth; |
|
|
|
if (orientation % 180 != 0) { |
|
|
|
outWidth = options.outHeight; |
|
|
|
outHeight = options.outWidth; |
|
|
|
|
|
|
|
outWidth = options.outHeight; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.inSampleSize = computeSampleSize(outWidth, outHeight, maxWidth, maxHeight); |
|
|
|
|
|
|
|
options.inJustDecodeBounds = false; |
|
|
|
|
|
|
|
bitmap = BitmapFactory.decodeByteArray(source, 0, source.length, options); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
bitmap = BitmapFactory.decodeByteArray(source, 0, source.length); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
options.inSampleSize = computeSampleSize(outWidth, outHeight, maxWidth, maxHeight); |
|
|
|
if (orientation != 0 || flip) { |
|
|
|
options.inJustDecodeBounds = false; |
|
|
|
Matrix matrix = new Matrix(); |
|
|
|
bitmap = BitmapFactory.decodeByteArray(source, 0, source.length, options); |
|
|
|
matrix.setRotate(orientation); |
|
|
|
} else { |
|
|
|
// matrix.postScale(1, -1) Flip... needs testing.
|
|
|
|
bitmap = BitmapFactory.decodeByteArray(source, 0, source.length); |
|
|
|
Bitmap temp = bitmap; |
|
|
|
} |
|
|
|
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); |
|
|
|
|
|
|
|
temp.recycle(); |
|
|
|
if (orientation != 0 || flip) { |
|
|
|
} |
|
|
|
Matrix matrix = new Matrix(); |
|
|
|
} catch (OutOfMemoryError e) { |
|
|
|
matrix.setRotate(orientation); |
|
|
|
// Create blank bitmap if out of memory to avoid crash
|
|
|
|
// matrix.postScale(1, -1) Flip... needs testing.
|
|
|
|
int dummySize = 100; |
|
|
|
Bitmap temp = bitmap; |
|
|
|
bitmap = Bitmap.createBitmap(dummySize, dummySize, Bitmap.Config.ARGB_8888); // this creates a MUTABLE bitmap
|
|
|
|
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); |
|
|
|
|
|
|
|
temp.recycle(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return bitmap; |
|
|
|
return bitmap; |
|
|
|
} |
|
|
|
} |
|
|
|