We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Creating black and white image (C# .NET)

I’m trying to create a black and white, i.e. 1bpp, PNG image but the image is always saved as grayscale anyway. Here’s my code:

        var bwOptions = new Aspose.Imaging.ImageOptions.PngOptions();
        bwOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.IndexedColor;
        bwOptions.Palette = ColorPaletteHelper.CreateMonochrome();
        bwOptions.BitDepth = 1;
        bwOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"bw.png", false);

        using (Image outputImg = Image.Create(bwOptions, 512, 512))

Am I missing something?

Thanks in advance and best regards,


I have observed your requirements and suggest you to please visit following thread for your kind reference. I hope the shared example will be helpful. I also suggest you to please try using method RasterImage.BinarizeFixed,RasterImage.BinarizeOtsu and RasterImage.BinarizeBradley as well.