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

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

Create Stopwatch App in Android using Sketchware

Codes for modifying Action Bar in Sketchware

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

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

How to integrate Admob Ads in Sketchware project using AIDE?

Firebase Login/Register with email verification