How can I specify the bitmap format (e.g. RGBA_8888) with BitmapFactory.decode*()?

前端 未结 2 2037
耶瑟儿~
耶瑟儿~ 2021-01-02 02:41

I\'m making several calls to BitmapFactory.decodeFile() and BitmapFactory.decodeResource(), and I\'d like to specify the format the bitmaps are dec

相关标签:
2条回答
  • 2021-01-02 03:08

    When you have bitmap you can call copy method on it specifying BitmapConfig which is basically what you want. http://developer.android.com/reference/android/graphics/Bitmap.html#copy(android.graphics.Bitmap.Config,boolean)

    0 讨论(0)
  • 2021-01-02 03:09

    This might be what you are looking for:

    BitmapFactory.Options op = new BitmapFactory.Options();
    op.inPreferredConfig = Bitmap.Config.ARGB_8888;
    bitmap = BitmapFactory.decodeFile(path, op);
    
    0 讨论(0)
提交回复
热议问题