Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi,

I am trying to draw text on image using drawstring method of graphics object.

I am using below code to draw the string in vertical

In my code i am using the namespace: using System.Drawing;

StringFormat formatver = new StringFormat(StringFormatFlags.DirectionVertical);

But the text is coming from Top to Bottom.
I want to print this string from Bottom to Top.

Please guide me..

Thanks
venkat.
Posted
Updated 18-Jan-12 20:37pm
v3
Comments
Sergey Alexandrovich Kryukov 19-Jan-12 1:43am    
It depends on what are you using. You need to tag it: WPF, Forms, Silverlight, ASP.NET, what? The solutions are very different. For example, in WPF this is not a problem at all.
--SA
venkatrao palepu 19-Jan-12 1:45am    
Hi SAKryukov,

Thanks fro the quick reply.
I am using ASP.NET and C#.NET..

Thanks
venkat.
Sergey Alexandrovich Kryukov 19-Jan-12 1:49am    
Sorry, are you sure? Are you really using System.Drawing in ASP.NET? For what, for making a bitmap? It's possible.
Also, I tried to add some tags to your question, but the server failed.

At first opportunity, please do yourself a favor, add "ASP.NET" and "System.Drawing" (if this is correct; clarify your question). You are the most interested, as you to attract right experts to your page, before on opens it, the tags are shown in the list. You really want it, believe me. If you are ready, please use "Improve question" above.
--SA
Sergey Alexandrovich Kryukov 19-Jan-12 1:58am    
I just completed the answer in assumption you use System.Drawing and you did not answer my question yet. OK, how is that? If my answer is relevant (I'm sure it works perfectly with System.Drawing), please accept my answer formally (green button) -- thanks.
--SA

1 solution

If you are using System.Drawing, StringFormat might be not universal enough for you.

This is one much more universal tool which will allow you to change orientation and do other linear transformations with ease. What you need is the property System.Drawing.Graphics.Transform, please see http://msdn.microsoft.com/en-us/library/system.drawing.graphics.transform.aspx[^].

You can assign different values to the property Trasform in the middle of rendering. For example, assign instance of transform, draw a string vertically, restore transform to the saved default value or change its orientation — draw another string horizontally or at the angle or draw something else.

You can apply any affine transform. For example, this method is the only way to render, say, a text written on a wall of a box depicted at the angle in some projection…

—SA
 
Share this answer
 
Comments
venkatrao palepu 19-Jan-12 2:12am    
Hi SAKryukov,

I have tried using RotateTransform(180) method. after using also I am not getting the text correctly.

Thanks
venkat.
Sergey Alexandrovich Kryukov 19-Jan-12 2:28am    
Apparently, rotate by -180 degrees then. :-)
Isn't this apparent, that an arbitrary affine transform will allow you to get any effect like mirroring, shear, etc.?
--SA
Amir Mahfoozi 19-Jan-12 2:22am    
+5
Sergey Alexandrovich Kryukov 19-Jan-12 2:29am    
Thank you, Amir.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900