public string WaterMark(string imagefile)
{
// Load an existing PNG image
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(imagefile))
{
// Declare a String object with Watermark Text
string theString = "Discarded";
// Create and initialize an instance of Graphics class and Initialize an object of SizeF to store image Size
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);
Aspose.Imaging.SizeF sz = graphics.Image.Size;
// Creates an instance of Font, initialize it with Font Face, Size and Style
Aspose.Imaging.Font font = new Aspose.Imaging.Font("Times New Roman", 20, Aspose.Imaging.FontStyle.Bold);
// Create an instance of SolidBrush and set its various properties
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
brush.Color = Aspose.Imaging.Color.Red;
brush.Opacity = 0;
// Initialize an object of StringFormat class and set its various properties
Aspose.Imaging.StringFormat format = new Aspose.Imaging.StringFormat();
format.Alignment = Aspose.Imaging.StringAlignment.Center;
format.FormatFlags = Aspose.Imaging.StringFormatFlags.MeasureTrailingSpaces;
Aspose.Imaging.Matrix matrix = new Aspose.Imaging.Matrix();
//First a translation
matrix.Translate(sz.Width / 2, sz.Height / 2);
//Then a rotation
matrix.Rotate(-45.0f);
//Set the Transformation through Matrix
graphics.Transform = matrix;
// Draw the string on Image Save output to disk
graphics.DrawString(theString, font, brush, 0, 0, format);
image.Save(imagefile);
}
I think this code do not work well!!
We are moving this inquiry to Aspose.Imaging forum category where you will be assisted accordingly.
I suggest you to please visit the following documentation link for your convenience.
If you still encounter issue then please share the source file and generated output along with issue detail on your end.
I make the same program as your sample program but It does not work …My source is attached to upper codes.