The pixel value obtained by the bitmap getpixel method in Android is negative.

Source: Internet
Author: User

Recently, I am working on Image Processing on Android and directly operating on pixels on Android. Unexpectedly, some unexpected things have occurred. The getpixel method of Bitmap class obtains all negative pixel values. It should have been black, that is, 0, and all values have changed to-16777216, which is very strange. However, it is quite special to study this 16777216 carefully because 16777216 = 256*256*256, which is the product of the maximum values of the three RGB color components. In fact, we are very familiar with the inaccurate expression of this value. We often say that 16 million colors are supported when we advertise the screen on mobile phones. Nokia prefers this promotion. -In hexadecimal notation of 16777216, the complement code is # ff000000, which is exactly the opaque black with the Alpha Channel added. Check android
In Android, the color is composed of four components. I assume that YY is the RGB component and the component is ignored. The default a value is 255. Therefore, the highest bit of a pixel in a graph without Channel A is always 1, and there is no unsigned integer in Java. A 32-bit int type variable is returned, which leads to various negative numbers I have encountered.

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.