"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
Just a guess, but I would try using the Graphics.FromImage() method to
get a Graphics object and then you should be able to do your overlay
with that.
Thanks. I figured I needed a Graphics object, and also that I'd need the
FromImage() method to get my image into a form I could lay text on.
Here's my code so far...
' I have my image data as a System.IO.Stream but
' I need a System.Drawing.Graphics object
' Graphics won't convert a stream but System.Drawing.Image
' will and Graphics will convert an Image so...
image = System.Drawing.Image.FromStream(ImageStream)
graphic = Graphics.FromImage(image)
' Now I have my image data as a Graphics object
' Set up tools for writing text...
myBrush = New Drawing2D.HatchBrush(Drawing2D.HatchStyle.Trellis,
Color.FromArgb(127, Color.White))
myFont = New Font("Arial black", 144)
' Use the DrawString() method of the graphics object to
' overlay the text (tell me if I'm wrong, please)
graphic.DrawString("PROOF", myFont, myBrush, New RectangleF(10, 10, 100,
200))
' I can convert a Stream to a byte array and that's what
' I need to output. I can convert a Bitmap into a Stream, so...
' Create a Bitmap of the correct width and
' hieght using my Grpahics object image
imgOutput = New Bitmap(image.Width, image.Height, graphic)
' Prepare a new Stream
imgStream = New MemoryStream
' Send the Bitmap down the Stream
imgOutput.Save(imgStream, image.RawFormat)
' Prepare the Byte array to take the stream data
ReDim imgbin(imgStream.Length)
' Set the pointer to the start of the stream
imgStream.Position = 0
' Stream the Bitmap data into the Byte array
n = imgStream.Read(imgbin, 0, imgbin.Length)
That's the plan, anyway.
I end up with an image the right size but all black.
I don't see how I can even debug this stuff - there's nothing I can look at
between steps to show me where my graphic is up to.
I'm stuck.
Brian Lowe
---------@