0

I have bitmap 2592x2048 8bit i tried several basic variants of resize, and after each variants pxlFormat changed to 32 bit. How can i avoid this ?

Answer You need to create a copy of the desired size, and convert the image to 8 bit (using http://www.wischik.com/lu/programmer/1bpp.html)

1 Answers1

0

Not to comment on your resizing approach, but your specific error comes from the fact that you are returning a new Bitmap(30, 24). Within the constructor, there is no argument to specify the PixelFormat so it has taken the default: Format32bppArgb.

Try, for example:

Bitmap resizedImg = new Bitmap(50, 50,System.Drawing.Imaging.PixelFormat.Format24bppRgb);
George Kerwood
  • 1,248
  • 8
  • 19
  • If I create ` Bitmap resizedImg = new Bitmap(50,50,System.Drawing.Imaging.PixelFormat.Format8bppIndexed); ` It'll be new empty bitmap, and I'll have to write pxl myself. In theory this will work, but if there is a ready-made optimized method, I don’t want to complicate – Михаил Руденко May 25 '20 at 10:03
  • See the answer to this question: https://stackoverflow.com/questions/1922040/how-to-resize-an-image-c-sharp/24199315. There are many ways to perform the resize, but to your original question, if you want a specific `PixelFormat`, you have to specify it in the constructor of the `Bitmap`. – George Kerwood May 25 '20 at 10:08