Converting Bitmap in memory to Bitmap with Bitmap.Config.RGB_565

后端 未结 3 954
囚心锁ツ
囚心锁ツ 2020-12-25 14:18

I have a loaded Bitmap which I would like to convert to set the config to Bitmap.Config.RGB_565. Is there a simple way of converting a Bitmap to th

3条回答
  •  忘掉有多难
    2020-12-25 14:43

    You can also try this:

    Bitmap converted = original.copy(Config.RGB_565, false);
    

    From the documentation of Bitmap.copy():

    Tries to make a new bitmap based on the dimensions of this bitmap, setting the new bitmap's config to the one specified, and then copying this bitmap's pixels into the new bitmap. If the conversion is not supported, or the allocator fails, then this returns NULL.

    Looking through the native source code, you should be fine converting between any values of Bitmap.Config.

提交回复
热议问题