0

How do I get C# to force bitmap images that are saved to be saved as 24-bit images as can be seen when you get the right-click properties of the image in Windows. All the images I save are set to 32-bit. I tried the below code with no luck. The source images are all 24-bit as well but are always saved as 32-bit image

    public void Save(int index)
    {

        string savestrFilename;
         SaveFileDialog dialog = new SaveFileDialog();

        dialog.Title = "image save...";
        dialog.OverwritePrompt = true;
        dialog.Filter = "JPEG File(*.jpg)|*.jpg|Bitmap File(*.bmp)|*.bmp";

        if (dialog.ShowDialog() == DialogResult.OK)
        {
            savestrFilename = dialog.FileName;
            System.IO.FileStream stream = new System.IO.FileStream(savestrFilename , System.IO.FileMode.Create);
            JpegBitmapEncoder encoder = new JpegBitmapEncoder();
            encoder.QualityLevel = 70;
            encoder.Frames.Add(BitmapFrame.Create(_grabImageList[index].BitmapImage));
            encoder.Save(stream);
            stream.Close();
        }

    }
Dmitry
  • 6,716
  • 14
  • 37
  • 39
장재훈
  • 1
  • 1
  • 1
    Possible duplicate of [Generate image file with low bit depths?](https://stackoverflow.com/questions/483014/generate-image-file-with-low-bit-depths) – Vj- Oct 12 '17 at 07:04
  • The currently stored bitmap bit is 8 bits. – 장재훈 Oct 12 '17 at 07:08
  • I wouldn't consider this a duplicate. This code to me suggests the use of a System.Windows.Media.BitmapImage, rather than System.Drawing.Bitmap. The solution from the referenced question may not be applicable to this use case. – Élie Oct 12 '17 at 10:25
  • Possible duplicate of [Converting 32 bit bmp to 24 bit](https://stackoverflow.com/questions/12572352/converting-32-bit-bmp-to-24-bit) – Christian Junk Jan 04 '18 at 09:09
  • [Converting 32 bit bmp to 24 bit](https://stackoverflow.com/questions/12572352/converting-32-bit-bmp-to-24-bit) – Christian Junk Jan 04 '18 at 09:09

0 Answers0