C # paint program saves bitmaps in different formats
I am working on a program that should be basically a paint program, but with the ability to save the drawn image as 5 formats or so. So I figured out that in order to save it I need to draw a bitmap. But when I try to save the image, I only have one option in the dropdown menu and it shows two formats next to each other and it always saves it as .bmp. http://s8.postimg.org/97wj3x2v9/Bez_n_zvu.jpg
I am using the save file dialog. How can I save it in other formats? For example .jpg, .png and others?
This is the save code I actually had.
{
saveFileDialog1.Filter = "Image Files (*.bmp, *.jpg)|*.bmp;*.jpg";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
bitmapa.Save(saveFileDialog1.FileName);
}
}
source to share
The filter is divided into two parts: description
filter and filter pattern
. For each format you need a "filter" (new description and template). So, for .bmp, .jpg and .png
:
"Bmp Files (*.bmp)|*.bmp |Jpeg Files (*.jpg)|*.jpg |Png Files (*.png)|*.png";
description pattern description pattern description pattern
And if you want to use a common filter for all three formats:
"Image Files (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png|Bmp Files (*.bmp)|*.bmp|Jpeg Files (*.jpg)|*.jpg|Png Files (*.png)|*.png";
source to share