diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs index c93c05226..0ac5739c5 100644 --- a/GreenshotPlugin/Core/ImageHelper.cs +++ b/GreenshotPlugin/Core/ImageHelper.cs @@ -967,6 +967,27 @@ namespace GreenshotPlugin.Core { return bb.Bitmap; } } + + /// + /// Returns a b/w of Bitmap + /// + /// Bitmap to create a b/w off + /// b/w bitmap + public static Bitmap CreateMonochrome(Image sourceImage) { + using (BitmapBuffer bb = new BitmapBuffer(sourceImage, true)) { + bb.Lock(); + for (int y = 0; y < bb.Height; y++) { + for (int x = 0; x < bb.Width; x++) { + Color color = bb.GetColorAt(x, y); + int colorBrightness = (color.R+color.G+color.B > 382) ? 255 : 0; + Color monoColor = Color.FromArgb(color.A, colorBrightness, colorBrightness, colorBrightness); + bb.SetColorAt(x, y, monoColor); + } + } + bb.Unlock(); + return bb.Bitmap; + } + } /// /// Create a new bitmap where the sourceBitmap has a Simple border around it