Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place Text in Image on Edges

enter image description here This tool I wrote in Visual Basic 2010 should add an author text to images. The user is able to set the font opacity and position. To make things easier I wanted some position presets as one can see in the bottom right corner. The calculation I am using is (bottom right in this case:

 Dim textSize As Size = TextRenderer.MeasureText(tagString + curText, curFont)
 tmpPos = New Point(srcImg.Width - textSize.Width - 10, srcImg.Height - textSize.Height - 10)

As you can see this works perfectly for this example picture. Where as on some the text just clips out. enter image description here

First One: 1024x768 | Detected Font Size: 680x72

Second One: 1688x1125 | Detected Font Size: 680x72

I suspect this has something to do with the aspect ratio of the images but I do not know how to fix it.

The text is drawn like that:

 brush = New SolidBrush(color.FromArgb(alpha, color))
        gr = Graphics.FromImage(editImg)
        gr.DrawString(tagString + text, font, brush, pos)
        HauptBild.Image = editImg

I found this http://www.codeproject.com/Articles/20923/Mouse-Position-over-Image-in-a-PictureBox and it answered my questions.

like image 499
Trojan Avatar asked Dec 17 '15 16:12

Trojan


1 Answers

is this problem only occuring in your preview or also in the converted File? Please post the Code how you save the New Image. I think you have Set a sizemode in your picturebox which is the Problem. Try it without the sizemode.

like image 174
etalon11 Avatar answered Oct 21 '22 12:10

etalon11