byteをBitmapに変換し、メモリオーバーフローを防止
1745 ワード
- Java
-
- ByteArrayInputStream is =new ByteArrayInputStream(byte[]);
- BitmapFactory.Options options=new BitmapFactory.Options();
- options.inPurgeable = true;
- options.inInputShareable = true;
- options.inSampleSize = 2;
- try {
- BitmapFactory.Options.class.getField("inNativeAlloc").setBoolean(options,true);
- } catch(Exception ex) {
- ex.printStackTrace();
- }
- Bitmap imgBit = (new WeakReference<Bitmap>(BitmapFactory.decodeStream(is, null, options))).get();