mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 18:57:28 -07:00
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:
parent
190578953c
commit
b692674f38
1 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue