Android programming realizes the method of obtaining image pixel data based on bitmap _android

Source: Internet
Author: User

This article is an example of the Android programming implementation based on bitmap to obtain image pixel data methods. Share to everyone for your reference, specific as follows:

The references on the Internet are:

int[] pixels = new Int[bit.getwidth () *bit.getheight ()];//saves an array of all pixels, with a picture wide x high
bit.getpixels (Pixels,0,bit.getwidth ( ), 0,0,bit.getwidth (), Bit.getheight ());
for (int i = 0; i < pixels.length i++) {
   int clr = pixels[i];
    int red  = (CLR & 0x00ff0000) >> 16;//High two-bit
    int green = (CLR & 0x0000ff00) >> 8;//two-digit
    int Blue = clr & 0x000000ff; Lower two-bit
    System.out.println ("r=" +red+ ", g=" +green+ ", b=" +blue ")
;

Where the third parameter in Getpixels is the width of the picture

Actually, there's a better function

Bitmap BM = "Get Bitmap picture";
Bm.getpixels (X,y);

The pixel data at the x,y coordinates are obtained directly.

I hope this article will help you with the Android program.

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.