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;