added CreateMonochrome(Image), which creates a black/white version of the image (not accessible via UI yet, needs some more testing)

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2466 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
JKlingen 2013-02-06 22:11:21 +00:00
commit b692674f38

View file

@ -967,6 +967,27 @@ namespace GreenshotPlugin.Core {
return bb.Bitmap;
}
}
/// <summary>
/// Returns a b/w of Bitmap
/// </summary>
/// <param name="sourceImage">Bitmap to create a b/w off</param>
/// <returns>b/w bitmap</returns>
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;
}
}
/// <summary>
/// Create a new bitmap where the sourceBitmap has a Simple border around it