using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using AForge.Imaging; using AForge.Imaging.Formats; namespace Image_Viewer { public partial class ImageViewerForm : Form { public ImageViewerForm() { InitializeComponent(); } private void viewImageButton_Click(object sender, EventArgs e) { if ( openFileDialog1.ShowDialog( ) == DialogResult.OK ) { loadImageFromFile(openFileDialog1.FileName); } } private void loadImageFromFile(String filename) { ImageInfo imageInfo = null; FileInfo fileInfo = new FileInfo(filename); String name = fileInfo.Name; pictureBox.Image = ImageDecoder.DecodeFromFile(filename, out imageInfo); int bitsPerPixel =imageInfo.BitsPerPixel; int imageWidth = imageInfo.Width; int imageHeight = imageInfo.Height; String imageInfoString = name + "\n" + bitsPerPixel + " bits per pixel \n" + imageWidth + "x" + imageHeight + " pixels "; MessageBox.Show(imageInfoString); } } }