android - bmpFactoryOptions don't work, no idea why -
i use following code blob sqlite database , bitmap. problem reconstructed bitmap larger original picture (input). seems bitmapfactory.options isn't working, have no idea wrong, nor getting error. wrong code?
byte[] blob = contact.getmp(); bytearrayinputstream inputstream = new bytearrayinputstream(blob); bitmapfactory.options bmpfactoryoptions = new bitmapfactory.options(); bmpfactoryoptions.inpreferredconfig = bitmap.config.argb_8888; bmpfactoryoptions.inscaled = false; bmpfactoryoptions.outheight = 240; bmpfactoryoptions.outwidth = 320; bitmap bitmap = bitmapfactory.decodestream(inputstream, null, bmpfactoryoptions); try { fileoutputstream out = new fileoutputstream("mnt/sdcard/test5.png"); bitmap.compress(bitmap.compressformat.png, 100, out); } catch (exception e) { e.printstacktrace(); }
when check output 320 x 240 picture 427 x 320. don't want use bitmap.createscaledbitmap because messes quality.
you have pass decodestream
in order work
bitmap bitmap = bitmapfactory.decodestream(inputstream, null, bmpfactoryoptions);
Comments
Post a Comment