Skip to content

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

@shaoguanglin

Description

@shaoguanglin

-----------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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions