Android Image Processing (3) Negative Effects

Source: Internet
Author: User

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 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.