Pixel format of Bitmap

Source: Internet
Author: User
1. Determine the pixel format of the bitmap:
 
VaR bit: tbitmap; pix: tpixelformat; s: string; begin bit: = tbitmap. create; bit. loadfromfile ('C: \ temp \ test.bmp '); // bitmap path pix: = bit. pixelformat; s: = ''; Case pix of pfdevice: S: = 'device'; {the pixel format supported by the device} pf1bit: S: = '1bit '; pf4bit: s: = '4bit '; pf8bit: S: = '8bit'; pf15bit: S: = '15bit '; pf16bit: S: = '16bit'; pf24bit: s: = '24bit '; pf32bit: S: = '32bit'; pfcustom: S: = 'custom'; {other formats} end; showmessage (s); bit. free; end;

  

2. pixel format conversion of Bitmap:

 
VaR bit: tbitmap; begin bit: = tbitmap. create; bit. loadfromfile ('C: \ temp \ test.bmp '); bit. pixelformat: = pf4bit; bit. savetofile ('C: \ temp \ test2.bmp '); bit. free; end;

  

3. Save the bitmap in the specified pixel format:

 var bit: tbitmap; begin bit: = self. getformimage; // obtain the form customer area as an image without bit: = tbitmap. create; bit. pixelformat: = pf1bit; bit. savetofile ('C: \ temp \ test.bmp '); bit. free; // but end needs to be released;

   

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.