tags:

views:

256

answers:

4

I'm building a Bitmap by layering images one above another, and when I'm done I want to write text around the edges. The top and bottom are simple because they're written horizontally, but I'd prefer to write the text on the left and right sides vertically so they don't take up as much space.

The Graphics.DrawString method doesn't allow you to specify an angle of rotation; what other methods exist?

+1  A: 

Here is a tutorial that may help http://www.c-sharpcorner.com/Blogs/BlogDetail.aspx?BlogId=580

I believe StringFormatFlags.DirectionVertical is what you are looking for

apocalypse9
+2  A: 

I think you may get some pointers from this answer about rotating text for printing that I wrote a while ago.

Fredrik Mörk
A: 

Maybe you can rotate the bitmap 90 degrees and write the text to the top of the bitmap - then rotate again and write the next side's text - this would give you text running CW/CCW around the edges.

If you want it horizontally across the top and bottom and vertically on the left and right, I suggest measuring (or assumning) the size of the largest character you need to write and then use this to position the drawn text - one character at a time - first on the left side then the right then moving down one char and repeating. You could of course just right the left side in totality and then the right side. just use the width of the char to inset from the right side and the height of the char to offset vertically between chars.

e.g.

1         2     OR     1         4      GIVING   C        D
3         4            2         5               A        O
5         6            3         6               T        G

Probably not the most elegant solution, but may help you.

A: 

You can use a logical font for this. But it's a pain - you're better off using Fredrik's answer (unless you're doing this in the Compact Framework, where RotateTransform isn't available).

MusiGenesis