Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can drawString method be used for writing diagonal way

I am using c# 2005 i want to write string diagonally on image. But by default c# provides the option to write horizontally or vertically.

how we write diagonally?

Thanks

like image 995
SelvirK Avatar asked Sep 18 '08 10:09

SelvirK


2 Answers

You can use the RotateTransform and TranslateTransform that are available on the Graphics class. Because using DrawString is GDI+ the transforms affects the drawing. So use something like this...

g.RotateTransform(45f);
g.DrawString("My String"...);
g.RotateTransform(-45f);

Don't forget to reverse the change though!

like image 114
Phil Wright Avatar answered Oct 26 '22 05:10

Phil Wright


Do a Graphics.rotateTransform before the drawString call. Don't forget to reverse the change afterwards, as Phil Wright points out.

like image 23
moonshadow Avatar answered Oct 26 '22 06:10

moonshadow