Example #1
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     try {
         var dial = new OpenFileDialog();
         if ((bool)dial.ShowDialog()) {
             var img = new Bmp4Image(dial.FileName);
             image.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                 img.PixelData.GetHbitmap(),
                 IntPtr.Zero,
                 Int32Rect.Empty,
                 BitmapSizeOptions.FromWidthAndHeight(img.Width, img.Height)
             );
             textBox.Clear();
             textBox.AppendText($"\nFile size: {img.FileSize}\n");
             textBox.AppendText($"Bit count: {img.BitCount}\n");
             textBox.AppendText($"Compression: {img.Compression}\n");
             textBox.AppendText($"Header size: {img.HeaderSize}\n");
             textBox.AppendText($"Height: {img.Height}\n");
             textBox.AppendText($"Width: {img.Width}\n");
             textBox.AppendText($"Color palette:\n");
             foreach (var c in img.ColorPalette) {
                 textBox.AppendText($"- {c.ToString()}\n");
             }
         }
     } catch(Exception ex) {
         textBox.AppendText($"Error: {ex.Message}");
     }
 }
Example #2
0
 public void TestBmpReader()
 {
     foreach (var file in Directory.GetFiles(imgPath, "*.bmp")) {
         var b4img = new Bmp4Image(file);
         var img = new Bitmap(file);
         CollectionAssert.AreEqual(img.GetPixels().ToList(), b4img.PixelData.GetPixels().ToList(), "Image pixels should be equal.");
     }
 }
Example #3
0
 public void TestBmpType()
 {
     using (var s = new FileStream($"{imgPath}PNG.png", FileMode.Open)) {
         var img = new Bmp4Image(s);
     }
 }