Mike_Lowe 2005-05-28 02:42 #563 Hi, My client requires huge copyright messages to be dynamically displayed across all images posted on their website. How do I overlay text on an image but allowing the image underneath the text to be still visible (i.e. opacity of the text to be reduced) ? I would appreciate if you could show a quick snippet in C#. Many thanks, Mike
Dmitry 2005-05-28 04:58 #3632 Hello,
You can insert watermarks on your images using the following code snippet:
// Input text string, offset of text output and source bitmap.
System.String text = "Aurigma Inc.";
System.Drawing.PointF offset = new System.Drawing.PointF(30.0F, 30.0F);
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.Yellow,
200, 200, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);
// Convert bitmap to rgb color space.
bitmap.ColorManagement.ConvertToContinuous(Aurigma.GraphicsMill.ColorSpace.Rgb, false, false);
// Create font instance.
System.Drawing.Font font = new System.Drawing.Font("Arial", 14);
System.Drawing.Graphics graphics = bitmap.GetGdiplusGraphics();
try
{
// Create solid brush with opacity.
System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(Color.FromArgb(0x9F, 0x00, 0x00, 0x00));
// Draw text string.
graphics.DrawString(text, font, brush, offset);
}
finally
{
font.Dispose();
graphics.Dispose();
}
// Save result bitmap.
bitmap.Save(@"c:/1.png");
If you have some questions, please fill free to contact me.
Mike_Lowe 2005-05-28 14:51 #3633 Thank you for your suggestion. Mike