Android. getRGB get is negative, solution

Source: Internet
Author: User

Scenario: Ava.awt.color The following getRGB how to draw a negative number??? Originally want to get an integer by getRGB, in another part in accordance with this integer component a color, because the parameters can only be passed an integer!!! How does color get an integer????

Solution: getRGB () returns the RGB value that represents the color in the default SRGB ColorModel. (24-31-bit indicates that the ALPHA,16-23 bit represents red, 8-15 bits are green, and 0-7 bits represent blue).

To get a specific r,g,b, the color component has to be shifted.
Color color
int RGB = COLOR.GETRGB ();
int r = (RGB & 16711680) >> 16;
int g = (RGB & 65280) >> 8;
int b = (RGB & 255);

You can also use the getred (), Getgreen (), GetBlue () method of color directly to get r,g,b.

Android. getRGB get is negative, solution

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.