Skip to content

Commit

Permalink
Merge pull request #8978 from garymathews/TIMOB-24465
Browse files Browse the repository at this point in the history
[TIMOB-24465] Android: Use ARGB_8888 by default
  • Loading branch information
ssjsamir committed May 2, 2017
2 parents 27b7366 + 7649ed3 commit 30a9911
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ private Bitmap getImage(BitmapFactory.Options opts) {

if (opts == null) {
opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
}

// The only opts that can be used to uniquely name an image is the inSampleSize
Expand Down Expand Up @@ -714,7 +714,7 @@ public TiBlob imageAsResized(Number width, Number height)

opts = new BitmapFactory.Options();
opts.inSampleSize = sampleSize;
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,25 +743,7 @@ public static KrollDict viewToImage(KrollDict proxyDict, View view)
view.layout(0, 0, width, height);
}

// opacity should support transparency by default
Config bitmapConfig = Config.ARGB_8888;

Drawable viewBackground = view.getBackground();
if (viewBackground != null) {
/*
* If the background is opaque then we should be able to safely use a space saving format that
* does not support the alpha channel. Basically, if a view has a background color set then the
* the pixel format will be opaque. If a background image supports an alpha channel, the pixel
* format will report transparency (even if the image doesn't actually look transparent). In
* short, most of the time the Config.ARGB_8888 format will be used when viewToImage is used
* but in the cases where the background is opaque, the lower memory approach will be used.
*/
if (viewBackground.getOpacity() == PixelFormat.OPAQUE) {
bitmapConfig = Config.RGB_565;
}
}

Bitmap bitmap = Bitmap.createBitmap(width, height, bitmapConfig);
Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public Bitmap getBitmap(boolean needRetry, boolean densityScaled)
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inInputShareable = true;
opts.inPurgeable = true;
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
if (densityScaled) {
DisplayMetrics dm = new DisplayMetrics();
dm.setToDefaults();
Expand Down

0 comments on commit 30a9911

Please sign in to comment.