I have a System.Drawing.Image screenshot file. I cast it to bmp, but the problem is that it makes a 32 bit bmp, while I need a 24 bit one. How can I convert it to 24?
try this code:
public static Bitmap ConvertTo24bpp(Image img) {
var bmp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
using (var gr = Graphics.FromImage(bmp))
gr.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height));
return bmp;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With