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 8681085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:24:50+00:00 2026-06-12T21:24:50+00:00

while searching for a solution to automatically put a watermark to an image in

  • 0

while searching for a solution to automatically put a watermark to an image in internet, i found a best solution in stackoverflow. Link for the question is C# – Add watermark to the photo by special way. My special thanks to Alex Maslakov and adrift.

I implemented that solution with some modifications, i want to put watermark in center of the image. I modified the solution provided by adrift as follows

   private void button1_Click(object sender, EventArgs e)
    {
        using (Image image = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"))
        using (Image watermarkImage = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\watermark.png"))
        using (Graphics imageGraphics = Graphics.FromImage(image))
        using (Brush watermarkBrush = new TextureBrush(watermarkImage))
        {
            int x = (image.Width - watermarkImage.Width)/2;
            int y = (image.Height - watermarkImage.Height)/2;
            imageGraphics.FillRectangle(watermarkBrush, new Rectangle(new Point(x, y), watermarkImage.Size));
            image.Save(@"C:\Users\Public\Pictures\Sample Pictures\Desert_watermark.jpg");
        }

    }

but watermark is not properly placed in the center of image (see below image).

enter image description here

please correct me…

thanks

  • 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-06-12T21:24:51+00:00Added an answer on June 12, 2026 at 9:24 pm

    Finally i find the solution to my question…

    The corrected code answer is following

        private void button1_Click(object sender, EventArgs e)
        {
            using (Image image = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg"))
            using (Image watermarkImage = Image.FromFile(@"C:\Users\Public\Pictures\Sample Pictures\watermark.png"))
            using (Graphics imageGraphics = Graphics.FromImage(image))
            using (TextureBrush watermarkBrush = new TextureBrush(watermarkImage))
            {
                int x = (image.Width / 2 - watermarkImage.Width / 2);
                int y = (image.Height / 2 - watermarkImage.Height / 2);
                watermarkBrush.TranslateTransform(x, y);
                imageGraphics.FillRectangle(watermarkBrush, new Rectangle(new Point(x, y), new Size(watermarkImage.Width+1, watermarkImage.Height)));
                image.Save(@"C:\Users\Public\Pictures\Sample Pictures\Desert_watermark.jpg");
            }
    
        }
    

    my thanks to Furqan Safdar and Abdias Software
    The link Problem in tiling image starting at different height using TextureBrush in C# also helped me to solve this problem

    and thanks all

    finally result

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found similar questions while searching for a solution for my problem but I
I have been searching on the internet for a while now, for a solution
While searching for a solution to a python regular expression problem I found this
I've been searching a solution for a while but couldn't find any. I do
i was searching for a while, but couldn't find a fitting solution: My Case:
While searching the web, I found this code: $apprequest_url =https://graph.facebook.com/ . /apprequests?ids=USERID_1,USERID_2,USERID_3 . &message='INSERT_UT8_STRING_MSG'
While searching a bug in my code today I found a strange thing. When
I have been searching for a solution to this for a while and have
I spent my day searching on the internet a solution to my problem without
i've been searching SO for a while and found nothing related to this. We

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.