相关疑难解决方法(0)

C# - 通过特殊方式为照片添加水印

我需要通过特殊方式为照片添加水印.我知道怎么做,但我不知道如何做到这一点与文章http://www.photoshopessentials.com/photo-effects/copyright/相同

这是添加水印的方法.如何更改它以获得带有水印的图像,例如上面的文章?

public static Bitmap AddWatermark(this Bitmap originalImage, Bitmap watermarkImage, WatermarkLocationEnum location)
{
    int offsetWidth;
    int offsetHeight;
    if ((watermarkImage.Width > originalImage.Width) | (watermarkImage.Height > originalImage.Height))
        throw new Exception("The watermark must be smaller than the original image.");
    Bitmap backgroundImage = new Bitmap((Bitmap)originalImage.Clone());
    Bitmap image = new Bitmap(backgroundImage.Width, backgroundImage.Height);
    Graphics graphics = Graphics.FromImage(image);
    offsetWidth = GetOffsetWidth(image.Width, watermarkImage.Width, location);
    offsetHeight = GetOffsetHeight(image.Height, watermarkImage.Height, location);
    watermarkImage.SetResolution(backgroundImage.HorizontalResolution, backgroundImage.VerticalResolution);
    offsetWidth = Math.Max(offsetWidth - 1, 0);
    offsetHeight = Math.Max(offsetHeight - 1, 0);
    graphics.DrawImage(watermarkImage, offsetWidth, offsetHeight); …
Run Code Online (Sandbox Code Playgroud)

algorithm image-processing winforms c#-4.0

13
推荐指数
1
解决办法
5490
查看次数

使用C#中的TextureBrush在不同高度开始的平铺图像问题

我试图使用TextureBrush在尺寸宽度= 1000,高度= 16的矩形区域上平铺图像(16x16)以获得像UI一样的条带.

 Rectangle myIconDrawingRectangle = new Rectangle(x, y, 1000, 16);
 using (TextureBrush brush = new TextureBrush(myIcon, WrapMode.Tile))
 {
    e.Graphics.FillRectangle(brush, myIconDrawingRectangle );
 }
Run Code Online (Sandbox Code Playgroud)

当我用x = 0绘制时,y = 0平铺从(0,0)开始按预期发生.

当我用x = 0绘制时,y = 50平铺从(0,50)开始,但绘制矩形不是从图像的开头开始.它从图像的裁剪部分开始,然后重复.

怎么解决这个?

PS:我不想在DrawImage上重复手动循环.

c# tiling image

3
推荐指数
1
解决办法
2819
查看次数

标签 统计

algorithm ×1

c# ×1

c#-4.0 ×1

image ×1

image-processing ×1

tiling ×1

winforms ×1