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

After the background transparent PNG is converted to BPG, it is converted to PNG by bpg_ decoder for preservation, and the transparent background becomes black #7

Open
shaoguanglin opened this issue Mar 23, 2020 · 0 comments

Comments

@shaoguanglin
Copy link

-----------use bpg_decoder get a bitmap:
public static Bitmap getDecodedBpgBitmap(Context context, File bpgFile) throws FileNotFoundException {
Bitmap bm = null;
try {
FileInputStream fis = new FileInputStream(bpgFile);
byte[] byteArray = toByteArray(fis);
byte[] decBuffer = null;
int decBufferSize = 0;
decBuffer = DecoderWrapper.decodeBuffer(byteArray, byteArray.length);
decBufferSize = decBuffer.length;

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        options.inDither=false;

        if (decBuffer != null) {
           bm = BitmapFactory.decodeByteArray(decBuffer, 0, decBufferSize,options);
        }
    } catch (IOException ex) {
        TLog.e("getDecodedBpgBitmap", "Failed to convert image to byte array");
    }
    return bm;
}

--------------and save the bitmap to PNG ,but the transparent background became to black.
bpgBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant