TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
andrew
NA
155
0
Drawing Stretched Text
Oct 10 2003 11:25 AM
here is another question for gdi+ gurus: I have a rectangle on a screen that I need to fit text into. The text needs to be centered vertically, and fit horizontally from left to right so that characters will be stretched or shrunk depending on the size of the rectangle. I tried using ScaleTransform, and it seems to work almost, but the text always starts too far from the beginning. Here is what I'm doing now: SizeF size = g.MeasureString(text, font, 4000, format); float isWidth = size.Width; float needWidth = Width; float scale = needWidth / (isWidth > 0 ? isWidth : 1); g.TranslateTransform(-X, -Y); g.ScaleTransform(scale, 1); g.TranslateTransform(X, Y); g.DrawString(text, font, brush, LayoutRectangle, format); i think i must do something different with translateTransform to make it work property. Any ideas? Thanks.
Reply
Answers (
2
)
Saving Metafiles
PictureBox and antialiasing (smoothing)