I want to add a png file as watermark on tiff file. I used Aspose.Imaging.Brushes.TextureBrush class,but it did not work. Also I did not find method to set opacity of the watermark and I dont know if the watermark could keep the original color but not turn black and white.
Here is my current test code
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(img))
{
// Load the watermark image
string watermarkPath = @"D:\AI\水印.png";
using (Aspose.Imaging.Image watermark = Aspose.Imaging.Image.Load(watermarkPath))
{
// Set the watermark position and scale
double x = 100;
double y = 100;
double width = 200;
double height = 200;
// Create a brush from the watermark image
var brush = new Aspose.Imaging.Brushes.TextureBrush(watermark);
// Add the watermark to the TIF file
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
graphics.FillRectangle(brush, new Aspose.Imaging.RectangleF((float)x, (float)y, (float)width, (float)height));
// Save the modified TIF file
string savePath = Path.Combine(@"C:\Users\xj2ssf\Desktop\EDM_test",
string.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(img),
DateTime.Now.ToString("yyyy_MM_dd_hh_mm_fff"),
Path.GetExtension(img)));
image.Save(savePath);
}
}