Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WaterMark
- {
- public WaterMark()
- {
- //-------MADE BY PATPOSITRON-------------
- //-This watermark class was made by------
- //-PatPositron on HF. Reuse as needed----
- //-------PLEASE LEAVE CREDITS HERE-------
- }
- /// <summary>
- /// WaterMark the image with a string.
- /// </summary>
- /// <param name="location">Location of desired image.</param>
- /// <param name="mark">The string used to mark the image.</param>
- /// <param name="x">The X-Coordinate where the watermark will be located.</param>
- /// <param name="y">The Y-Coordinate where the watermark will be located.</param>
- public static Image Mark(string location, string mark, int x, int y)
- {
- Image img = Image.FromFile(location);
- Image image = new Bitmap(img.Width, img.Height);
- Graphics G = Graphics.FromImage(image);
- G.DrawImage(img, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
- img.Dispose();
- G.DrawString(mark, new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Pixel), new SolidBrush(Color.FromArgb(75, 0, 0, 0)), new Point(x,y));
- G.Dispose();
- return image;
- }
- /// <summary>
- /// WaterMark the image with another Image.
- /// </summary>
- /// <param name="location">Location of desired image.</param>
- /// <param name="mark">The image used to watermark the desired image.</param>
- /// <param name="x">The X-Coordinate where the watermark will be located.</param>
- /// <param name="y">The Y-Coordinate where the watermark will be located.</param>
- public static Image Mark(string location, Image markImage, int x, int y)
- {
- Image img = Image.FromFile(location);
- Image image = new Bitmap(img.Width, img.Height);
- Graphics G = Graphics.FromImage(image);
- ColorMatrix cm = new ColorMatrix();
- cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = cm.Matrix44 = 1;
- cm.Matrix33 = 0.3F;
- ImageAttributes ia = new ImageAttributes();
- ia.SetColorMatrix(cm);
- G.DrawImage(img, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
- img.Dispose();
- G.DrawImage(markImage, new Rectangle(x, y, markImage.Width, markImage.Height), 0, 0, markImage.Width, markImage.Height, GraphicsUnit.Pixel, ia);
- G.Dispose();
- return image;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment