public void ShouldBeAbleToConvertGrayImage()
            {
                using (var image = new MagickImage(ToMagickColor(Color.Magenta), 5, 1))
                {
                    image.ColorType = ColorType.Bilevel;
                    image.ClassType = ClassType.Direct;

                    using (var bitmap = image.ToBitmapWithDensity())
                    {
                        for (int i = 0; i < image.Width; i++)
                        {
                            ColorAssert.Equal(MagickColors.White, ToMagickColor(bitmap.GetPixel(i, 0)));
                        }
                    }
                }
            }
            private void AssertSupportedImageFormat(ImageFormat imageFormat)
            {
                using (var image = new MagickImage(MagickColors.Red, 10, 10))
                {
                    using (var bitmap = image.ToBitmapWithDensity(imageFormat))
                    {
                        Assert.Equal(imageFormat, bitmap.RawFormat);

                        // Cannot test JPEG due to rounding issues.
                        if (imageFormat != ImageFormat.Jpeg)
                        {
                            ColorAssert.Equal(MagickColors.Red, ToMagickColor(bitmap.GetPixel(0, 0)));
                            ColorAssert.Equal(MagickColors.Red, ToMagickColor(bitmap.GetPixel(5, 5)));
                            ColorAssert.Equal(MagickColors.Red, ToMagickColor(bitmap.GetPixel(9, 9)));
                        }
                    }
                }
            }
            public void ShouldBeAbleToConvertRgbaImage()
            {
                using (var image = new MagickImage(ToMagickColor(Color.Magenta), 5, 1))
                {
                    image.Alpha(AlphaOption.On);

                    using (var bitmap = image.ToBitmapWithDensity())
                    {
                        var color = MagickColors.Magenta;
                        color.A = Quantum.Max;

                        for (int i = 0; i < image.Width; i++)
                        {
                            ColorAssert.Equal(color, ToMagickColor(bitmap.GetPixel(i, 0)));
                        }
                    }
                }
            }