Graphics Bitmap Compression

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

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation