绘图机制及技巧

2016-07-12  本文已影响18人  jacky123

1.颜色处理

  1. 颜色矩阵 ColorMatrix 4*5 (RGBA)
Bitmap bmp = Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
canvas.drawBitmap(bitmap,0,0,paint);    //将原图 bitmap 绘制到该 bmp 中
mImageView.setImageBitmap(bmp);

2.像素点

int[] oldPx = new int[width * height];
int[] newPx = new int[width * height];
bm.getPixels(oldPx, 0, width, 0, 0, width, height);

2.变形

变形矩阵 (平移 旋转 缩放 错切) Matrix 3*3

怎么样将一个图片旋转 30°,然后平移到 (100,100) 的地方?

a.
    Matrix matrix = new Matrix();
    matrix.postRotate(30);          //后乘
    matrix.postTranslate(100,100);
b.
    Matrix matrix = new Matrix();
    matrix.setTranslate(100,100);
    matrix.preRotate(30);           //前乘

像素块
drawBitmapMesh

上一篇 下一篇

猜你喜欢

热点阅读