Convert 32 to BMP to 24 bits

Source: Internet
Author: User

The 32-bit BMP is used to read the video frame. Because 24-bit BMP is used, a conversion is required. The method is very simple: remove the Alpha value of each pixel in 32 bits,

Byte * ptemp; // known 32-Bit Data

Byte * pdata24;

DWORD dwsize32; // known, 32-bit size

DWORD dwsize24;

 

Dwsize24 = (dwsize32 * 3)/4;

Pdata24 = new byte [dwsize24];

For (INT Index = 0; index <dwsize32/4; index ++) // The total number of pixels

{

Unsigned char r = * (ptemp ++ );

Unsigned char G = * (ptemp ++ );

Unsigned char B = * (ptemp ++ );

(Ptemp ++); // remove alpha

* (Pdata24 ++) = R;

* (Pdata24 ++) = g;

* (Pdata24 ++) = B;

}

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.