/// <summary> /// Binarizes the specified bitmap /// </summary> /// <param name="bitmap">Bitmap</param> /// <returns></returns> public static Bitmap Binarize(Bitmap bitmap) { Bitmap resultImage = bitmap; GdPictureImaging image = new GdPictureImaging(); int imageId = image.CreateGdPictureImageFromBitmap(bitmap); if (imageId > 0) { image.FxBlackNWhite(imageId, BitonalReduction.Stucki); image.ConvertTo1BppFast(imageId); resultImage = image.GetBitmapFromGdPictureImage(imageId).CloneSmart(image.GetPixelFormat(imageId)); image.ReleaseGdPictureImage(imageId); } return(resultImage); }