Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting from image to graphics and back again
Message
De
31/07/2007 18:21:45
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Photos et traitement d'images
Titre:
Converting from image to graphics and back again
Divers
Thread ID:
01245045
Message ID:
01245045
Vues:
54
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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform