Exemple #1
0
        public void Asserts_bmp_header_identifier()
        {
            var bitmap = _sut.Encode(new RgbBitmap(new List <IRgbColor> {
                new RgbColor()
            }, 1, 1)).ToArray();

            bitmap[0].Should().Be((byte)'B');
            bitmap[1].Should().Be((byte)'M');
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            var pixels = new List <IRgbColor>
            {
                new RgbColor(0, 0, 255),
                new RgbColor(0, 255, 0),
                new RgbColor(255, 0, 0),
                new RgbColor(255, 255, 255),
            };
            var rgbBitmap = new RgbBitmap(pixels, 2, 2);

            var pngImageEncoder = PngImageEncoderFactory.Create();

            File.WriteAllBytes("test.png", pngImageEncoder.Encode(rgbBitmap).ToArray());

            var bmpImageEncoder = new BmpImageEncoder();

            File.WriteAllBytes("test.bmp", bmpImageEncoder.Encode(rgbBitmap).ToArray());
        }