Here is a small code that I wrote to find the image format of an image.
This code will check for the raw image format of the image you select and will display in a pop up window.
Hope this helps.
- using System.Drawing.Imaging;
- private void button1_Click(object sender, EventArgs e)
- {
- openFileDialog1.ShowDialog();
- Image img = Image.FromFile(openFileDialog1.FileName);
- ImageFormat imgfmt = img.RawFormat;
- if (imgfmt.Equals(ImageFormat.Bmp))
- MessageBox.Show(ImageFormat.Bmp.ToString());
- else if (imgfmt.Equals(ImageFormat.Jpeg))
- MessageBox.Show(ImageFormat.Jpeg.ToString());
- else if (imgfmt.Equals(ImageFormat.Tiff))
- MessageBox.Show(ImageFormat.Tiff.ToString());
- else if (imgfmt.Equals(ImageFormat.Wmf))
- MessageBox.Show(ImageFormat.Wmf.ToString());
- else if (imgfmt.Equals(ImageFormat.Icon))
- MessageBox.Show(ImageFormat.Icon.ToString());
- else if (imgfmt.Equals(ImageFormat.Png))
- MessageBox.Show(ImageFormat.Png.ToString());
- else if (imgfmt.Equals(ImageFormat.Gif))
- MessageBox.Show(ImageFormat.Gif.ToString());
- }
No comments:
Post a Comment