Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting from image to graphics and back again
Message
From
01/08/2007 14:22:11
 
 
To
31/07/2007 18:21:45
General information
Forum:
ASP.NET
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
01245045
Message ID:
01245207
Views:
22
I finally found out that there is no conversion necessary because the graphics object is a representation of the image, i.e. they are one and the same. Amazing the assumptions one makes all on one's own...


>I need to write text, e.g. "Copyright", on top of a photograph and then save the photo with the text embedded in it to a file and/or a database.
>
>
>Dim Canvas As Graphics
>Dim image1 As Bitmap
>
>Canvas = Graphics.FromImage(Photo.Image)
>Dim PhotoImage As Image
>PhotoImage = Photo.Image
>
>Dim GridColor As Color = Color.White
>Dim GridBrush As New SolidBrush(GridColor)
>Dim GridPen As New Pen(GridColor)
>Dim GridFont As New Font("Verdana", 12, FontStyle.Bold)
>Canvas.DrawString("Copyright", GridFont, GridBrush, 10, 10)
>
>' Line below causes Graphics type cannot be converted to Bitmap error
>image1 = Canvas
>PhotoImage = image1
>
>' Draw image to screen.
>e.Graphics.DrawImage(image1, New PointF(0.0F, 0.0F))
>
>
>
>As you can see, I tried using a bitmap as a transitional stage between an image and a graphics object, but that didn't work. What I think I need is a ToImage method that does the opposite of the FromImage method.
>
>Any suggestions would be gratefully received,
>David.
Previous
Reply
Map
View

Click here to load this message in the networking platform