mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Added the area (Rectangle) to the FastBitmap, this made it possible to convert the current filters (all but the BlurFilter, this I want to review). Still want to see if I can change the way the filters work, maybe I can prevent some extra bitmap actions by changing the flow & signatures... Need to start in DrawableContainer.DrawContent.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2484 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
5ffe3dfb42
commit
d77d4d9ddf
5 changed files with 103 additions and 46 deletions
|
@ -23,6 +23,7 @@ using System.Drawing;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Core;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace Greenshot.Drawing.Filters {
|
||||
[Serializable()]
|
||||
|
@ -47,24 +48,23 @@ namespace Greenshot.Drawing.Filters {
|
|||
return;
|
||||
}
|
||||
|
||||
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||
bbb.Lock();
|
||||
using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) {
|
||||
double brightness = GetFieldValueAsDouble(FieldType.BRIGHTNESS);
|
||||
for (int y = 0; y < bbb.Height; y++) {
|
||||
for (int x = 0; x < bbb.Width; x++) {
|
||||
for (int y = 0; y < fastBitmap.Height; y++) {
|
||||
for (int x = 0; x < fastBitmap.Width; x++) {
|
||||
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||
Color color = bbb.GetColorAt(x, y);
|
||||
Color color = fastBitmap.GetColorAt(x, y);
|
||||
int r = Convert.ToInt16(color.R * brightness);
|
||||
int g = Convert.ToInt16(color.G * brightness);
|
||||
int b = Convert.ToInt16(color.B * brightness);
|
||||
r = (r > 255) ? 255 : r;
|
||||
g = (g > 255) ? 255 : g;
|
||||
b = (b > 255) ? 255 : b;
|
||||
bbb.SetColorAt(x, y, Color.FromArgb(color.A, r, g, b));
|
||||
fastBitmap.SetColorAt(x, y, Color.FromArgb(color.A, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
bbb.DrawTo(graphics, applyRect.Location);
|
||||
fastBitmap.DrawTo(graphics, applyRect.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,19 +40,18 @@ namespace Greenshot.Drawing.Filters {
|
|||
return;
|
||||
}
|
||||
|
||||
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||
bbb.Lock();
|
||||
for (int y = 0; y < bbb.Height; y++) {
|
||||
for (int x = 0; x < bbb.Width; x++) {
|
||||
using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) {
|
||||
for (int y = 0; y < fastBitmap.Height; y++) {
|
||||
for (int x = 0; x < fastBitmap.Width; x++) {
|
||||
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||
Color color = bbb.GetColorAt(x, y);
|
||||
Color color = fastBitmap.GetColorAt(x, y);
|
||||
int luma = (int)((0.3 * color.R) + (0.59 * color.G) + (0.11 * color.B));
|
||||
color = Color.FromArgb(luma, luma, luma);
|
||||
bbb.SetColorAt(x, y, color);
|
||||
fastBitmap.SetColorAt(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
bbb.DrawTo(graphics, applyRect.Location);
|
||||
fastBitmap.DrawTo(graphics, applyRect.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ using System.Drawing;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Core;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace Greenshot.Drawing.Filters {
|
||||
[Serializable()]
|
||||
|
@ -46,19 +47,18 @@ namespace Greenshot.Drawing.Filters {
|
|||
return;
|
||||
}
|
||||
|
||||
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||
bbb.Lock();
|
||||
using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) {
|
||||
Color highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
|
||||
for (int y = 0; y < bbb.Height; y++) {
|
||||
for (int x = 0; x < bbb.Width; x++) {
|
||||
for (int y = 0; y < fastBitmap.Height; y++) {
|
||||
for (int x = 0; x < fastBitmap.Width; x++) {
|
||||
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||
Color color = bbb.GetColorAt(x, y);
|
||||
Color color = fastBitmap.GetColorAt(x, y);
|
||||
color = Color.FromArgb(color.A, Math.Min(highlightColor.R, color.R), Math.Min(highlightColor.G, color.G), Math.Min(highlightColor.B, color.B));
|
||||
bbb.SetColorAt(x, y, color);
|
||||
fastBitmap.SetColorAt(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
bbb.DrawTo(graphics, applyRect.Location);
|
||||
fastBitmap.DrawTo(graphics, applyRect.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ using System.Drawing;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Core;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace Greenshot.Drawing.Filters {
|
||||
[Serializable]
|
||||
|
@ -40,23 +41,22 @@ namespace Greenshot.Drawing.Filters {
|
|||
}
|
||||
int magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR);
|
||||
|
||||
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||
int halfWidth = bbb.Size.Width / 2;
|
||||
int halfHeight = bbb.Size.Height / 2;
|
||||
bbb.Lock();
|
||||
using (BitmapBuffer bbbSrc = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||
for (int y = 0; y < bbb.Height; y++) {
|
||||
using (IFastBitmap destFastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) {
|
||||
int halfWidth = destFastBitmap.Size.Width / 2;
|
||||
int halfHeight = destFastBitmap.Size.Height / 2;
|
||||
using (IFastBitmap sourceFastBitmap = FastBitmap.Create(applyBitmap, applyRect)) {
|
||||
for (int y = 0; y < destFastBitmap.Height; y++) {
|
||||
int yDistanceFromCenter = halfHeight - y;
|
||||
for (int x = 0; x < bbb.Width; x++) {
|
||||
for (int x = 0; x < destFastBitmap.Width; x++) {
|
||||
int xDistanceFromCenter = halfWidth - x;
|
||||
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||
Color color = bbbSrc.GetColorAt(halfWidth - xDistanceFromCenter / magnificationFactor, halfHeight - yDistanceFromCenter / magnificationFactor);
|
||||
bbb.SetColorAt(x, y, color);
|
||||
Color color = sourceFastBitmap.GetColorAt(halfWidth - xDistanceFromCenter / magnificationFactor, halfHeight - yDistanceFromCenter / magnificationFactor);
|
||||
destFastBitmap.SetColorAt(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bbb.DrawTo(graphics, applyRect.Location);
|
||||
destFastBitmap.DrawTo(graphics, applyRect.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue