Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24465] Android: Use ARGB_8888 by default #8978

Merged
merged 4 commits into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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