[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Drawing a string at the bottom of the immage with 5px offset

yosh

11/20/2004 12:09:00 AM

How can i calculate where i should put my text if i want it at the bottom of a image?

i have gotten so far that i can write it at the top of the image with 5px offset but i dont really know
how to get the string drawn at the bottom on different images with different sizes and resolutions and so forth
can someone please tell me how to do it or direct me to a website that explains it?
i have googled and only come up with hope to do the actual text, wich i already know.

Thanks!
2 Answers

James Westgate

11/20/2004 12:30:00 AM

0

1. Measure the size of your test using Graphics.MeasureString
2. Get the Width and height of your image from Bitmap.Width etc
3. Subtract 1 from 2, use Graphics.FromImage and Graphics.DrawString

James

--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.cra...

Take the ERM Tour at http://www.flowchartc...

<yosh@liquidzone.net> wrote in message
news:OaKdned3lpOuFgPcRVnytg@giganews.com...
> How can i calculate where i should put my text if i want it at the bottom
> of a image?
>
> i have gotten so far that i can write it at the top of the image with 5px
> offset but i dont really know
> how to get the string drawn at the bottom on different images with
> different sizes and resolutions and so forth
> can someone please tell me how to do it or direct me to a website that
> explains it?
> i have googled and only come up with hope to do the actual text, wich i
> already know.
>
> Thanks!


Morten Wennevik [C# MVP]

11/20/2004 10:24:00 AM

0

On Sat, 20 Nov 2004 00:30:08 -0000, James Westgate
<jameswestgate@nospam.nospam> wrote:

> 1. Measure the size of your test using Graphics.MeasureString
> 2. Get the Width and height of your image from Bitmap.Width etc
> 3. Subtract 1 from 2, use Graphics.FromImage and Graphics.DrawString
>
> James
>

4. Before drawing the string, you might want to change the font size
based on image resolution or you might end up with different sized text.
I forgot the exact calculations but those should be easy enough using
something like (you might need to change things around)

Unknown font size Some value I forgot, possibly 1
----------------- = -------------------
Current font size Image.HorizontalResolution

--
Happy Coding!
Morten Wennevik [C# MVP]