Link to home
Start Free TrialLog in
Avatar of rafaelrgl
rafaelrgl

asked on

draw string in a bitmap

hi, i have this code:

    objBmpImage = New Bitmap(objBmpImage, New Size(960, 832))
    objGraphics = Graphics.FromImage(objBmpImage)
    objGraphics.SmoothingMode = SmoothingMode.AntiAlias
    objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias
    objGraphics.DrawString(vtext, New Font("Arial", 35, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel), Brushes.White, 30, 25)


how can i draw this string inside my working area of the bitmap, so if the string is small, then the size will be bigger to fill the space, if the string is bigger then the size  it will be small. and how to justify the text.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rafaelrgl
rafaelrgl

ASKER

hi idle_mind,

i´m sorry but i put the wrong line for the string, the right one is this one:

objGraphics.DrawString(vtext, New Font("Arial", 80, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel), Brushes.White, System.Drawing.RectangleF.FromLTRB(10, 120, 950, 810))

because the one i put before it~s just for one line, and i want to fit not only on the line but the text goes all the way to the end of the image, so i have an rectangleF, i need to scale to fit on this rectangle.

any help
emoreau,

this is not what i want, because i am doing inside an rectangleF, and not just one line so the thext goes inside a box, and i want to scale the font to fit this box, so, if i have long text, the font will be set smaller to fit the area i am printing the text, if the text is short the font will be bigger so it will fit this area.
Is the text supposed to wrap?...or does it have distinct lines that must stay on those lines and you want to maximize how those lines fit in the box?
it's suppose to wrap
and be justify