Android examples for Graphics:Bitmap Paint
draw Size At Bitmap
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuffXfermode; public class Main { public static void drawSizeAtBitmap(Bitmap bitmap) { if (bitmap == null) { return; } else {/* w ww . j av a 2s. co m*/ Paint paint = new Paint(); paint.setTextSize(20F); paint.setColor(0xff0000ff); paint.setAntiAlias(true); paint.setXfermode(new PorterDuffXfermode( android.graphics.PorterDuff.Mode.SRC)); paint.setTextAlign(android.graphics.Paint.Align.CENTER); paint.setShadowLayer(1.0F, 0.0F, 0.0F, -1); Canvas canvas = new Canvas(bitmap); android.graphics.Paint.FontMetrics fontmetrics = paint .getFontMetrics(); float f = (1 + bitmap.getWidth()) / 2; float f1 = ((float) bitmap.getHeight() - (fontmetrics.descent + fontmetrics.ascent)) / 2.0F; canvas.drawText((new StringBuilder()).append(bitmap.getWidth()) .append("x").append(bitmap.getHeight()).toString(), f, f1, paint); return; } } }