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

  • Home
  • SEARCH
  • 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 7185821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:29:59+00:00 2026-05-28T18:29:59+00:00

I’m drawing a String with g.DrawString on an image. Before I’m doing this I’m

  • 0

I’m drawing a String with g.DrawString on an image. Before I’m doing this I’m also drawing images on the source image.

This is what my code looks like:

Bitmap sourceBitmap = Image.FromFile(myBitmap) as Bitmap;
Graphics g = Graphics.FromImage(sourceBitmap);

// drawing some other images on sourceBitmap with g.DrawImage

int positionx = 100;
Font ftemp = cvt.ConvertFromString(myfont) as Font; // predefined font
SizeF mysize = TextRenderer.MeasureText(mytext, ftemp); 
PointF myposition = new PointF(positionx - mysize.Width, positiony) // align right
g.DrawString(mytext, ftemp, new SolidBrush(mycolor), myposition);

That’s what I get: enter image description here

If I now add these two lines before the already mentioned code like this:

Bitmap sourceBitmap = Image.FromFile(myBitmap) as Bitmap;
Graphics g = Graphics.FromImage(sourceBitmap);

// drawing some other images on sourceBitmap with g.DrawImage

sourceBitmap = new Bitmap(sourceBitmap); // sourceBitmap is the bitmap (png) I'm drawing on from the very beginning.
g = Graphics.FromImage((Image)sourceBitmap);

int positionx = 100;
Font ftemp = cvt.ConvertFromString(myfont) as Font; // predefined font
SizeF mysize = TextRenderer.MeasureText(mytext, ftemp); 
PointF myposition = new PointF(positionx - mysize.Width, positiony) // align right
g.DrawString(mytext, ftemp, new SolidBrush(mycolor), myposition);

I get this: enter image description here

I didn’t change anything besides these two lines. So my question is how is this happening.

  • 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-28T18:30:01+00:00Added an answer on May 28, 2026 at 6:30 pm

    Check the DPI of the source PNG. When you load a Bitmap from file, it loads the DPI that was recorded in the file. When you create a new Bitmap based on another Bitmap that’s already in memory, it resets it to the screen DPI. It does not carry over the original DPI setting.

    You can specify that your font be represented with GraphicsUnit.Pixel like this:

    Font f = new Font("Arial", 10.0f, GraphicsUnit.Pixel);
    

    Otherwise your font will scale with the DPI of the image. Image DPI is just used to define how large in real-world units (inches) the image is supposed to be. You may or may not want to use that information when scaling your text, depending on if you’re scaling it for print.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.