android.graphics.drawable.Drawable drawable = getDrawable(R.drawable.image);
Bitmap bitmap = ((android.graphics.drawable.BitmapDrawable)drawable).getBitmap();
//Source
imageview1.setImageBitmap(bitmap);
java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG,50,stream);
byte[] byteArray = stream.toByteArray();
Bitmap compressedBitmap = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);
//Result 50% Quality
imageview2.setImageBitmap(compressedBitmap);
Komentar