bitmap to place image within image (, c#)

Posted on 2009-04-22
Last Modified: 2012-05-06
I have started using Bitmap class to create images, from existing images.

Basically I have an image, which is nothing more than a background. I then create a Bitmap from the existing image, and use the DrawString to write something on this background. E.g. Company Name.

Now would it be possible to place on image (say for example a company logo) on this Bitmap? If yes, how would I go about it, what methods and arguments to use?

My code is as below... actually not mine, found it on the internet.
public Bitmap WaterMarkToImage(string ImagePath, string watermark)


        Bitmap bmp;

        bmp = new Bitmap(ImagePath);

        Graphics graphicsObject;

        int x, y;



            //create graphics object from bitmap            

            graphicsObject = Graphics.FromImage(bmp);


        catch (Exception e)


            Bitmap bmpNew = new Bitmap(bmp.Width, bmp.Height);

            graphicsObject = Graphics.FromImage(bmpNew);

            graphicsObject.DrawImage(bmp, new Rectangle(0, 0, bmpNew.Width, bmpNew.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel);

            bmp = bmpNew;


        int startsize = (bmp.Width / watermark.Length);

        //get the font size with respect to length of the string        

        //x and y cordinates to draw a string       

        x = 20;

        y = 80;//bmp.Height / 3;

        //System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(StringFormatFlags.DirectionVertical); -> draws a vertical string for watermark        

        System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(StringFormatFlags.NoWrap);

        //drawing string on Image        

        graphicsObject.DrawString(watermark, new Font("Verdana", startsize, FontStyle.Bold), new SolidBrush(Color.White), x, y, drawFormat);

        //new SolidBrush(Color.FromArgb(60, 255, 255, 255)) - water mark colour


        //return a water marked image       

        return (bmp);


//end then calling it

 Watermark wM = new Watermark(); 

        System.Drawing.Bitmap bmp = wM.WaterMarkToImage("C:/base.jpg", txtTitle.Text);


Open in new window

Question by:zeraxis_ee
    LVL 15

    Accepted Solution

    In line #16 of the example code it uses DrawImage. This is what you would use to draw the logo bitmap on the existing image, just as how you draw a string on the existing image
    LVL 15

    Expert Comment

    If in doubt, use the intellisense in VS to look through what methods & properties are available in an object (in this case the Graphics object).

    The intellisense should also describe what the method does and an explanation of what each parameter is. Also the MSDN documentation is pretty good:

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video discusses moving either the default database or any database to a new volume.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now