This article describes the negative effects of image special effects processing. As before, pixels are processed, and algorithms are universal.
Algorithm principle: the RGB values of the current pixel and the values after the difference of 255 are used as the RGB values of the current vertex.
Example:
ABC
Evaluate the negative effect of point B:
B. R = 255-B. R;
B. G = 255-B. G;
B. B = 255-B. B;
:
Source image
Code:
Package COM. color; import android. content. context; import android. graphics. bitmap; import android. graphics. bitmapfactory; import android. graphics. canvas; import android. graphics. color; import android. graphics. paint; import android. util. attributeset; import android. widget. imageview; public class colorview extends imageview {private paint mypaint = NULL; private Bitmap bitmap = NULL; private int width, height; private int [] oldpixels; private int [] newpixels; private int color, color2; private int pixelsr, pixelsg, pixelsb, pixelsa, pixelsr2, pixelsg2, pixelsb2; Public colorview (context, attributeset attrs) {super (context, attrs ); bitmap = bitmapfactory. decoderesource (context. getresources (), R. drawable. WW); width = bitmap. getwidth (); Height = bitmap. getheight (); oldpixels = new int [width * Height]; newpixels = new int [width * Height]; invalidate () ;}@ overrideprotected void ondraw (canvas) {super. ondraw (canvas); // obtain the pixel bitmap. getpixels (oldpixels, 0, width, 0, 0, width, height); For (INT I = 1; I