mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Fixed a potential issue with GetWindowLong, using a wrapper which decides upon the IntPtr size which call needs to be made.
Fixed the corner cut to work with a CreateRoundRectRgn, but made if it cuts configurable so people can turn it off. Added a CountColor method to ImageHelper.cs, which should be used to check if PrintWindow functions properly. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2236 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
0fd12ae5fc
commit
197d46c9b9
5 changed files with 71 additions and 68 deletions
|
@ -1074,6 +1074,37 @@ namespace GreenshotPlugin.Core {
|
|||
return ResizeBitmap(sourceBitmap, maintainAspectRatio, false, Color.Empty, newWidth, newHeight, out throwAway);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Count how many times the supplied color exists
|
||||
/// </summary>
|
||||
/// <param name="sourceBitmap">Bitmap to count the pixels of</param>
|
||||
/// <param name="colorToCount">Color to count/param>
|
||||
/// <param name="includeAlpha">true if Alpha needs to be checked</param>
|
||||
/// <returns>int with the number of pixels which have colorToCount</returns>
|
||||
public static int CountColor(Bitmap sourceBitmap, Color colorToCount, bool includeAlpha) {
|
||||
int colors = 0;
|
||||
int toCount = colorToCount.ToArgb();
|
||||
if (!includeAlpha) {
|
||||
toCount = toCount & 0xffffff;
|
||||
}
|
||||
using (BitmapBuffer bb = new BitmapBuffer(sourceBitmap, true)) {
|
||||
bb.Lock();
|
||||
for (int y = 0; y < bb.Height; y++) {
|
||||
for (int x = 0; x < bb.Width; x++) {
|
||||
int bitmapcolor = bb.GetColorAt(x, y).ToArgb();
|
||||
if (!includeAlpha) {
|
||||
bitmapcolor = bitmapcolor & 0xffffff;
|
||||
}
|
||||
if (bitmapcolor == toCount) {
|
||||
colors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
bb.Unlock();
|
||||
return colors;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scale the bitmap, keeping aspect ratio, but the canvas will always have the specified size.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue