How to make Image.Save save as a 24-bit image?

How can I force C # to force the preservation of bitmaps that will be saved as 24-bit images, which can be seen when you get the right-click properties of an image in Windows. All saved images are set to 32-bit. I tried the code below with no luck. The original images are also 24-bit, but are always saved as 32-bit images.

ImageCodecInfo bmpCodec = FindEncoder(ImageFormat.Bmp); EncoderParameters parameters = new EncoderParameters(); parameters.Param[0] = new EncoderParameter(Encoder.ColorDepth, 24); imgCheque.Save(DestinationFile.ToString(), bmpCodec, parameters); 

Images must be correctly 24 bits, as they are read by another program that cannot process 32-bit images.

Thanks in advance,

Soultech

+4
source share
2 answers

Is it used?

 // imgCheque source created somewhere else up here using (Bitmap blankImage = new Bitmap(imgCheque.Width, imgCheque.Height, PixelFormat.Format24bppRgb)) { using (Graphics g = Graphics.FromImage(blankImage)) { g.DrawImageUnscaledAndClipped(imgCheque, new Rectangle(Point.Empty, imgCheque.Size)); } ImageCodecInfo bmpCodec = FindEncoder(ImageFormat.Bmp); blankImage.Save(@"C:\TEMP\output.bmp", bmpCodec, null); } 
+2
source

Try it?

 ImageCodecInfo bmpCodec = FindEncoder(ImageFormat.Bmp); EncoderParameters parameters = new EncoderParameters(); parameters.Param[0] = new EncoderParameter(Encoder.ColorDepth, 24L); imgCheque.Save(DestinationFile.ToString(), bmpCodec, parameters); 
0
source

All Articles