Inspiration was a question in my kidoos forum. Here is the quick script:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            string text = "NinethSense";
 
            Image img = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\Tree.jpg");
 
            WaterMark(text, img);
            img.Save(@"C:\test.jpg");
            img.Dispose();
        }
 
        private void WaterMarkSingle(string text, Image img, float x, float y)
        {
            Graphics g = Graphics.FromImage(img);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
 
            g.DrawString(text, new Font("Courier New", 10), new SolidBrush(Color.FromArgb(75, 0, 0, 0)), x + 2, y + 2);
            g.DrawString(text, new Font("Courier New", 10), new SolidBrush(Color.FromArgb(75, 255, 255, 255)), x, y);
            g.Dispose();
        }
 
        private void WaterMark(string text, Image img)
        {
            WaterMarkSingle(text, img, 10, 100);
            WaterMarkSingle(text, img, 10, (img.Height / 2) - 50);
            WaterMarkSingle(text, img, 10, img.Height - 100);
 
            WaterMarkSingle(text, img, (img.Width/2)-50, 100);
            WaterMarkSingle(text, img, (img.Width / 2)-50, (img.Height / 2) - 50);
            WaterMarkSingle(text, img, (img.Width / 2)-50, img.Height - 100);
 
            WaterMarkSingle(text, img, img.Width  - 100, 100);
            WaterMarkSingle(text, img, img.Width - 100 , (img.Height / 2) - 50);
            WaterMarkSingle(text, img, img.Width - 100 , img.Height - 100);
        }
    }
}

 

Here is the sample output:

image

VN:F [1.1.6_502]
Rating: 5.0/5 (1 vote cast)
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati

Related posts:

  1. Return multiple values from a function
  2. Create SharePoint 3.0 Custom Properties
  3. MD5 encryption with c#
  4. Find your lucky number in c#
  5. Invoke a ASP.NET WebService from Flex