Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Bitmap with bit depth 1

$
0
0
The IsMonochrome is only used when an image is read by some of the image decoders. This will be moved to MagickReadSettings in the next release.

The BMP encoder will only write a 1 bit image if contains 2 colors and has a color palette. Below is an example that can help you accomplish this.
using (MagickImage image = new MagickImage("logo:"))
{
  // First reduce the colors
  image.ColorType = ColorType.Bilevel;

  // Or use Quantize/*
  image.Quantize(new QuantizeSettings()
  {
    Colors = 2
  });
  */// Tell image to use a color map
  image.ClassType = ClassType.Pseudo; 

  // HACK! For now you will have to add the code below, this will be fixed in the next release
  image.ChangeColorSpace(ColorSpace.sRGB);

  // Write 1 bit bmp
  image.Write(@"C:\logo.bmp");
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>