GDI and Rotating Text

T

trullock

Hi,

I want to use GDI to rotate some text at an angle and output the
resultant image to the asp.net response stream.

I can do that all fine, however what I'm struggling with is trimming
the whitespace from the resultant image.

What im doing is creating a blank canvas image (of arbitrarily large
size) and doing a translate transform to the centre, then applying a
rotate transform, then writing my text.

What i want to do is trim all the whitespace from around the edges. Is
there some way i can determine the width and height of the text ive
written to the image (after the transform) ?

I know i can manually get the text dimensions before the rotate, then
use some trig to work out how high and wide it would be after rotating
it but thats a bit of a pain if theres some function that will do it
for me

Thanks for any advice

Andrew
 
P

Peter Duniho

[...]
What i want to do is trim all the whitespace from around the edges. Is
there some way i can determine the width and height of the text ive
written to the image (after the transform) ?

I know i can manually get the text dimensions before the rotate, then
use some trig to work out how high and wide it would be after rotating
it but thats a bit of a pain if theres some function that will do it
for me

You wrote that you're transforming the Graphics before drawing to
accomplish the rotation. You can also use the Matrix that you've assigned
to the Graphics.Transform property to transform the rectangle you can
easily derive from the text measurement methods, by calling
Matrix.TransformPoints().

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Rotating a Picturebox 1
TEXT - ROTATING 2
Rotating a Text Box. 2
Rotating an image 1
Rotating Images 5
GDI and Image displays 1
rotating thumbnails 4
Help Rotating Text 4

Top