mirror of
https://github.com/Geckon01/Watermark.Net.git
synced 2026-07-11 04:31:54 +00:00
Added rotation support for image watermark
This commit is contained in:
@@ -25,7 +25,7 @@ namespace UnitTest
|
|||||||
Font = availableFont.CreateFont(1),
|
Font = availableFont.CreateFont(1),
|
||||||
Text = "Test",
|
Text = "Test",
|
||||||
Style = { Color = Color.White },
|
Style = { Color = Color.White },
|
||||||
Layout = { Position = ImagePosition.BottomCenter , RotateAngle = 90 }
|
Layout = { Position = ImagePosition.BottomCenter, RotateAngle = 45 }
|
||||||
};
|
};
|
||||||
|
|
||||||
var resultedImage = watermarker.ProcessImage("TestImages/2.png", "test/text", watermark);
|
var resultedImage = watermarker.ProcessImage("TestImages/2.png", "test/text", watermark);
|
||||||
@@ -105,7 +105,7 @@ namespace UnitTest
|
|||||||
Font = availableFont.CreateFont(1),
|
Font = availableFont.CreateFont(1),
|
||||||
Text = "Test",
|
Text = "Test",
|
||||||
Style = { Color = Color.White },
|
Style = { Color = Color.White },
|
||||||
Layout = { Position = ImagePosition.BottomCenter , RotateAngle = 90 }
|
Layout = { Position = ImagePosition.BottomCenter, RotateAngle = 45 }
|
||||||
};
|
};
|
||||||
|
|
||||||
var resultedImage = pipeline.ProcessImage("TestImages/2.png", "test/pipeline/text", watermark);
|
var resultedImage = pipeline.ProcessImage("TestImages/2.png", "test/pipeline/text", watermark);
|
||||||
@@ -123,7 +123,7 @@ namespace UnitTest
|
|||||||
|
|
||||||
var watermark = new ImageWatermark {
|
var watermark = new ImageWatermark {
|
||||||
ImagePath = "TestImages/sample_wm.png",
|
ImagePath = "TestImages/sample_wm.png",
|
||||||
Layout = { Position = ImagePosition.Center, Scale = 1 },
|
Layout = { Position = ImagePosition.Center, Scale = 1, RotateAngle = 45 },
|
||||||
Style = { Opacity = 1 }
|
Style = { Opacity = 1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ namespace UnitTest
|
|||||||
Text = "Test",
|
Text = "Test",
|
||||||
Font = availableFont.CreateFont(1),
|
Font = availableFont.CreateFont(1),
|
||||||
Style = { Color = Rgba32.ParseHex("FFFFFF50"), Pave = true },
|
Style = { Color = Rgba32.ParseHex("FFFFFF50"), Pave = true },
|
||||||
Layout = { Scale = 1f, Position = ImagePosition.TopLeft }
|
Layout = { Scale = 1f, Position = ImagePosition.TopLeft, RotateAngle = 45 }
|
||||||
};
|
};
|
||||||
|
|
||||||
var results = pipeline.ProcessDirectory("TestImages", "test/pipeline/text/dir", watermark);
|
var results = pipeline.ProcessDirectory("TestImages", "test/pipeline/text/dir", watermark);
|
||||||
@@ -167,7 +167,7 @@ namespace UnitTest
|
|||||||
|
|
||||||
var watermark = new ImageWatermark {
|
var watermark = new ImageWatermark {
|
||||||
ImagePath = "TestImages/sample_wm.png",
|
ImagePath = "TestImages/sample_wm.png",
|
||||||
Layout = { Position = ImagePosition.Center, Scale = 1},
|
Layout = { Position = ImagePosition.Center, Scale = 1, RotateAngle = 45},
|
||||||
Style = { Pave = true, Opacity = 1}
|
Style = { Pave = true, Opacity = 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,16 @@ namespace Watermark.Net.src.WatermarkNet.Core
|
|||||||
if (watermark.Style.Color != null)
|
if (watermark.Style.Color != null)
|
||||||
processingContext.BackgroundColor((Color)watermark.Style.Color);
|
processingContext.BackgroundColor((Color)watermark.Style.Color);
|
||||||
|
|
||||||
watermarkImage.Mutate(x => x.Resize(new Size((int)scaledWmWidth, (int)scaledWmHeight)));
|
watermarkImage = watermarkImage.Clone(x =>
|
||||||
|
{
|
||||||
|
x.Resize((int)scaledWmWidth, (int)scaledWmHeight);
|
||||||
|
|
||||||
|
if (watermark.Layout.RotateAngle != 0)
|
||||||
|
{
|
||||||
|
x.Rotate(watermark.Layout.RotateAngle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var wmPositionOrigin = CalcWatermarkOrigin(targetImage.Width, targetImage.Height, watermarkImage.Width, watermarkImage.Height, watermark.Layout.Position);
|
var wmPositionOrigin = CalcWatermarkOrigin(targetImage.Width, targetImage.Height, watermarkImage.Width, watermarkImage.Height, watermark.Layout.Position);
|
||||||
|
|
||||||
if (watermark.Style.Pave)
|
if (watermark.Style.Pave)
|
||||||
|
|||||||
Reference in New Issue
Block a user