How to draw with an "inverted" paint in Android Canvas?

I draw some stuff on a canvas, over I want to draw a circle in inverted color :

canvas.drawCircle(zx, zy, 8f, myPaint);

How to configure myPaint for circle pixel to be in the inverted color of the underlying pixels ?

Thanks


尝试这个

float mx [] = {
             -1.0f,  0.0f,  0.0f,  1.0f,  0.0f,
             0.0f,  -1.0f,  0.0f,  1.0f,  0.0f,
             0.0f,  0.0f,  -1.0f,  1.0f,  0.0f,
             1.0f,  1.0f,  1.0f,  1.0f,  0.0f 
    };
ColorMatrix cm = new ColorMatrix(mx);

p.setColorFilter(new ColorMatrixColorFilter(cm));

canvas.drawCircle(zx, zy, 8f, p);

I'd say a color matrix for inverting should look like this:

float mx [] = {
         -1.0f,  0.0f,  0.0f,  0.0f,  255.0f,
         0.0f,  -1.0f,  0.0f,  0.0f,  255.0f,
         0.0f,  0.0f,  -1.0f,  0.0f,  255.0f,
         0.0f,  0.0f,  0.0f,  1.0f,  0.0f 
};

Here is more information for the matrix:


myPaint.setColor(Integer.MAX_VALUE - color);
链接地址: http://www.djcxy.com/p/52572.html

上一篇: 流利的NHibernate Automapping抽象基类

下一篇: 如何在Android Canvas中使用“倒置”的绘画?