예제 #1
0
        static public void PrintPixelData(MonochromeBitmap bitmap, Boolean withBinary = true)
        {
            int    lineCounter = 0;
            string binaryLine  = "";

            foreach (byte chunk in bitmap.pixel_data)
            {
                Console.Write(chunk.ToString("X2"));
                Console.Write(" ");
                lineCounter++;
                if (withBinary)
                {
                    binaryLine += Convert.ToString(chunk, 2).PadLeft(8, '0');
                    binaryLine += " ";
                }

                if (lineCounter == 4)
                {
                    if (withBinary)
                    {
                        Console.Write(" | " + binaryLine);
                        binaryLine = "";
                    }
                    Console.Write("\n");
                    lineCounter = 0;
                }
            }
        }
예제 #2
0
        static public void PrintFormattedHeader(MonochromeBitmap bitmap)
        {
            Console.WriteLine("Signature | File Size    | Reserved     | Data Offset");
            PrintHexString(bitmap.signature);
            Console.Write("    | ");
            PrintHexString(bitmap.file_size);
            PrintDivider();
            PrintHexString(bitmap.reserved);
            PrintDivider();
            PrintHexString(bitmap.data_offset);
            PrintSpacer();

            Console.WriteLine("Size         | Width        | Height       | Planes | Bits Per Pixel");
            PrintHexString(bitmap.size);
            PrintDivider();
            PrintHexString(bitmap.width);
            PrintDivider();
            PrintHexString(bitmap.height);
            PrintDivider();
            PrintHexString(bitmap.planes);
            PrintDivider();
            PrintHexString(bitmap.bits_per_pixel);
            PrintSpacer();

            Console.WriteLine("Compression  | Image Size   | XpixelsPerM  | YpixelsPerM");
            PrintHexString(bitmap.compression);
            PrintDivider();
            PrintHexString(bitmap.image_size);
            PrintDivider();
            PrintHexString(bitmap.xPixelsPerM);
            PrintDivider();
            PrintHexString(bitmap.yPixelsPerM);
            PrintSpacer();

            Console.WriteLine("Colors Used  | Important Colors");
            PrintHexString(bitmap.colors_used);
            PrintDivider();
            PrintHexString(bitmap.important_colors);
            PrintSpacer();

            Console.WriteLine("Red | Green | Blue | Reserved");
            for (int chunk = 0; chunk < 4; chunk++)
            {
                Console.Write(bitmap.color_table[chunk].ToString("X2"));
                PrintDivider();
            }
            PrintSpacer();
            Console.WriteLine("Red | Green | Blue | Reserved");
            for (int chunk = 4; chunk < 8; chunk++)
            {
                Console.Write(bitmap.color_table[chunk].ToString("X2"));
                PrintDivider();
            }
            PrintSpacer();

            PrintPixelData(bitmap, true);
        }
예제 #3
0
 static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         Console.WriteLine("Usage: bmpinspector input_file.bmp");
     }
     else
     {
         MonochromeBitmap image = new MonochromeBitmap(args[0]);
         BitmapHelper.PrintFormattedHeader(image);
     }
 }