NOTE:-
CODE:
using System;
using System.Windows.Forms;
namespace FindImageFormatWF
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void LoadButton_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title="Select Image";
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
ofd.Filter = "Image Files(*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp";
if (ofd.ShowDialog() == DialogResult.OK)
{
string imgfile = ofd.FileName;
string extn = System.IO.Path.GetExtension(imgfile);
FileExtensionLabel.Visible = false;
FileExtensionLabel.Text = extn;
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
PictureBox1.Image = System.Drawing.Image.FromFile(imgfile);
}
}
private void GetFormatButton_Click(object sender, EventArgs e)
{
if (PictureBox1.Image!=null)
{
RawFormatLabel.Text = PictureBox1.Image.RawFormat.ToString();
PixelFormatLabel.Text = PictureBox1.Image.PixelFormat.ToString();
FileExtensionLabel.Visible = true;
}
}
}
}
No comments:
Post a Comment