For the first time I had a question that, despite a thorough search, it seems that they have not yet asked.
I have a problem with Bitmap.createScaledBitmap() , as a result, the resulting scaled raster map is always ARGB_8888 , regardless of the input configuration. Naturally, this is a problem when working with limited memory.
InputStream is; try { is = mAssets.open("test.png"); BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPreferredConfig = Config.ARGB_4444; Bitmap originalBitmap = BitmapFactory.decodeStream(is, null, opts); System.out.println("Original Config: " + originalBitmap.getConfig()); mScale = (float) mHeight / originalBitmap.getHeight(); mBitmapScaled = Bitmap.createScaledBitmap(originalBitmap, (int)(mScale*(float)originalBitmap.getWidth()), (int)(mScale*(float)originalBitmap.getHeight()), true); System.out.println("Scaled: " + mBitmapScaled.getConfig()); originalBitmap.recycle(); is.close(); } catch (IOException e) {
The above code returns the outputs:
Source Bitmart: ARGB_4444
Scaling: ARGB_8888
Since the Bitmap.createScaledBitmap() method does not accept the configuration, there is no way to prevent this. Any ideas?
source share