장재훈
장재훈

Reputation: 1

how to make Image save as a 24-bit image?

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();
        }

    }

Upvotes: 0

Views: 1972

Answers (0)

Related Questions