Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 566455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:58:45+00:00 2026-05-13T12:58:45+00:00

What i’m trying to do is write a string to an image without overlapping

  • 0

What i’m trying to do is write a string to an image without overlapping the image. So i want to watermark an image putting the watermark (string) at the bottom without actually affecting the image or stretching the image out. I already know how to turn a string into an image, just having problems accomplishing the watermark.

1) Write string to Image on bottom right hand side
2) don’t stretch the original image
3) extend the bitmap a little bit to include watermark?

Does anybody have an example or an idea where to start? If i don’t make any sense i’ll try to answer any questions.

Bitmap example:

here is the code I use to get the bitmap, how do I increase just the size by X like 20?

Bitmap original = (Bitmap)System.Drawing.Image.FromFile(coveted);
Bitmap newImage = new Bitmap(original);

And I guess the 2nd part is how do i determine the space that I need in order to write out a string to the very bottom right of the image, while fitting in the entire string…

@ROY: This is the edit that i did.

This sorta works but the one watermark appears below the other. if i could get them on the same line it would be perfect!

private static Bitmap WatermarkImage2(Bitmap bmpOriginal, String waterMark2)
    {
        using (Graphics gfxOriginal = Graphics.FromImage(bmpOriginal))
        {
            using (Font fntWatermark = new Font("Arial", 24, FontStyle.Regular))
            {
                SizeF szWatermark = gfxOriginal.MeasureString(waterMark2, fntWatermark, int.MaxValue);
                Bitmap bmpWatermarked2 = new Bitmap(bmpOriginal.Width, bmpOriginal.Height + (int)(szWatermark.Height * 2));
                using (Graphics gfxWatermarked = Graphics.FromImage(bmpWatermarked2))
                {
                    gfxWatermarked.Clear(Color.White);
                    gfxWatermarked.DrawImageUnscaled(bmpOriginal, 0, 0);
                    gfxWatermarked.DrawString(waterMark2, fntWatermark, Brushes.Black, 0, (bmpOriginal.Height + szWatermark.Height) - (szWatermark.Height / 2));
                }
                return bmpWatermarked2;
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:58:45+00:00Added an answer on May 13, 2026 at 12:58 pm

    This may work for you:

        private static Bitmap WatermarkImage(Bitmap bmpOriginal, String waterMarkLeft, String waterMarkRight)
        {
            using (Graphics gfxOriginal = Graphics.FromImage(bmpOriginal))
            {
                using (Font fntWatermark = new Font("Arial", 12, FontStyle.Regular))
                {                    
                    SizeF szWatermarkLeft = gfxOriginal.MeasureString(waterMarkLeft, fntWatermark, int.MaxValue);
                    SizeF szWatermarkRight = gfxOriginal.MeasureString(waterMarkRight, fntWatermark, int.MaxValue);
    
                    float heightWatermark = szWatermarkLeft.Height > szWatermarkRight.Height ? szWatermarkLeft.Height : szWatermarkRight.Height;
    
                    Bitmap bmpWatermarked = new Bitmap(bmpOriginal.Width, bmpOriginal.Height + (int)(heightWatermark * 2));
    
                    using (Graphics gfxWatermarked = Graphics.FromImage(bmpWatermarked))
                    {
                        gfxWatermarked.Clear(Color.White);
                        gfxWatermarked.DrawImageUnscaled(bmpOriginal, 0, 0);
                        gfxWatermarked.DrawString(waterMarkLeft, fntWatermark, Brushes.Black, 0, (bmpOriginal.Height + heightWatermark) - (szWatermarkLeft.Height / 2));
                        gfxWatermarked.DrawString(waterMarkRight, fntWatermark, Brushes.Black, (bmpOriginal.Width - szWatermarkRight.Width), (bmpOriginal.Height + heightWatermark) - (heightWatermark / 2));                        
                    }
    
                    return bmpWatermarked;                                        
                }
            }
        }
    

    Then you would call it like this:

    using (Bitmap bmpWatermarked = WatermarkImage((Bitmap)Bitmap.FromFile(@"c:\\test.bmp"), @"Copyright (C) A Corp."))
    {
        bmpWatermarked.Save(@"c:\watermarked.bmp");
    }
    

    Combined with your code above:

    Bitmap original = (Bitmap)System.Drawing.Image.FromFile(coveted); 
    Bitmap newImage = new Bitmap(original); 
    using (Bitmap bmpWatermarked = WatermarkImage(newImage, @"Copyleft (C) A Corp.", @"Copyright (C) B Corp."))
    {
      bmpWatermarked.Save(@"c:\watermarked.bmp");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 378k
  • Answers 378k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I investigated JMX and EJB in Glassfish few years ago,… May 14, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer Yep, thats correct. You don't need to use delete. The… May 14, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer I read that the maximum memory malloc can allocate is… May 14, 2026 at 9:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.