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 enable download in webview in Sketchware apps?

Create Stopwatch App in Android using Sketchware

A Flash Light App in Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

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

Firebase Login/Register with email verification

Codes for modifying Action Bar in Sketchware

Code for implementing Notifications in Sketchware