Make Logo - CSharp System.Drawing.Imaging

CSharp examples for System.Drawing.Imaging:Bitmap

Description

Make Logo

Demo Code


using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO;/*from  w w w.j a  v  a  2s .c  om*/
using System.Collections;
using System;

public class Main{

        public static void MakeLogo(Image img, string saveFile, string logoFile)
        {
            using (System.Drawing.Image logo = System.Drawing.Image.FromFile(logoFile))
            {
                if (img.Width < logo.Width || img.Height < logo.Height)
                    img.Save(saveFile);
                else
                {
                    Graphics g = System.Drawing.Graphics.FromImage(img);
                    Random r = new Random();
                    g.DrawImage(logo, img.Width - logo.Width - r.Next(img.Width - logo.Width), img.Height - logo.Height - r.Next(img.Height - logo.Height), logo.Width, logo.Height);

                    g.Save();
                    img.Save(saveFile);
                    g.Dispose();
                }
                logo.Dispose();
            }
        }
}

Related Tutorials