Code example for Bitmap

Methods: getHeightgetRowBytes

0
import android.graphics.RectF; 
 
public final class BitmapUtils { 
 
	public static int getSize(Bitmap bm) {
		return bm.getRowBytes() * bm.getHeight();
	} 
 
	public static Bitmap getScaled(Bitmap bm, int sidePx, boolean max) {
		float w = bm.getWidth();
		float h = bm.getHeight();
		float wRatio = sidePx / w;
		float hRatio = sidePx / h;
		float ratio = max ? Math.min(wRatio, hRatio) : Math.max(wRatio, hRatio);
		w = ratio * w;
		h = ratio * h;
		return Bitmap.createScaledBitmap(bm, (int) w, (int) h, true);
	} 
 
	public static Bitmap getSquare(Bitmap bm) {
		int w = bm.getWidth();