Code example for Bitmap

Methods: getByteCountgetHeightgetWidthrecycle

0
 
		Bitmap correctedSizeBitmap = Bitmap.createBitmap(width, height,
				Bitmap.Config.ARGB_4444);
 
		Canvas canvas = new Canvas(correctedSizeBitmap);
		Rect sourceRect = new Rect(0, 0, bitmap.getWidth() - 1,
				bitmap.getHeight() - 1);
		Rect destRect = new Rect(0, 0, correctedSizeBitmap.getWidth() - 1,
				correctedSizeBitmap.getHeight() - 1);
		canvas.drawBitmap(bitmap, sourceRect, destRect, plainPaint);
 
		bitmap.recycle();
 
		if (logBitmapStats) {
			logBitmapStats("4444", correctedSizeBitmap);
		} 
 
		return correctedSizeBitmap;
 
	} 
 
	@TargetApi(12) 
	public static void logBitmapStats(String name, Bitmap bitmap) {
 
		StringBuilder builder = new StringBuilder();
		builder.append("Bitmap (");
		builder.append(name);
		builder.append(")");
		builder.append(bitmap.getWidth());
		builder.append("x");
		builder.append(bitmap.getHeight());
 
		if (android.os.Build.VERSION.SDK_INT >= 12) {
			builder.append("  memory=");
			builder.append(bitmap.getByteCount() / 1024f);
			builder.append(" kbs");
		} 
 
		Log.d(TAG, builder.toString());
	} 
Contextual code suggestions in your IDE  Get Codota for Java