draw Bitmap Offset on Canvas - Android Graphics

Android examples for Graphics:Canvas

Description

draw Bitmap Offset on Canvas

Demo Code


//package com.java2s;
import android.graphics.Bitmap;
import android.graphics.PointF;

public class Main {
    public static PointF drawBitmapOffset(PointF center, Bitmap bitmap) {
        PointF offset = new PointF();
        if (bitmap == null || bitmap.getWidth() < 0) {
            return center;
        }/*w  ww .  j a  va2 s .  c  o  m*/
        offset.set(center.x - bitmap.getWidth() / 2,
                center.y - bitmap.getHeight() / 2);
        return offset;
    }
}

Related Tutorials