(TIP _ revision 0618) convert BMP 32-bit to 24-bit

Source: Internet
Author: User

There is no efficiency at all. It is completely a solution to the problem,

Bitmap BMP = new Bitmap (320,240, pixelformat. format24bpprgb );
Bitmap BMP 1 = new Bitmap ("C: \ aa.bmp ");
For (INT I = 1; I <240; I ++)
{
For (Int J; j <320; j ++)
{
BMP. setpixel (J, I, BMP. getpixel (J, I );
}
}

BMP. Save ("D: \ cc.bmp", system. Drawing. imaging. imageformat. BMP );

Find a new method, thanks to csdn netizen -------------> http://topic.csdn.net/t/20050226/10/3807935.html
Way 1:

1 bitmap BMP 1 = new Bitmap ("C: \ aa.bmp ");
2 bitmapdata BD = BMP 1.lockbits (New rectangle (0, 0, BMP 1.width, BMP 1.height), imagelockmode. readonly, pixelformat. format24bpprgb );
3 bitmap BMP = new Bitmap (BMP 1.width, BMP 1.height, Bd. stride, Bd. pixelformat, Bd. scan0 );
4 BMP. Save ("D: \ mm.bmp", system. Drawing. imaging. imageformat. BMP );
5 BMP 1.unlockbits (BD );

Way 2:

1 bitmap BMP 1 = new Bitmap ("C: \ aa.bmp ");
2 bitmapdata BD = BMP 1.lockbits (New rectangle (0, 0, BMP 1.width, BMP 1.height), imagelockmode. readwrite, pixelformat. format24bpprgb );
3 bitmap BMP = BMP 1.clone (New rectangle (0, 0, BMP 1.width, BMP 1.height), Bd. pixelformat );
4 BMP. Save ("D: \ hh.bmp", system. Drawing. imaging. imageformat. BMP );
5 BMP 1.unlockbits (BD );

BMP resource processing ..........

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.