' Specify the picture you want to add the watermark text to
Dim img as Image = Image.FromFile (Server.MapPath ("~/upload/1.jpg"))
' Create a Bitmap object for the drawing operation (you cannot directly manipulate a format other than BMP, possibly)
Dim Bitmap as New bitmap (343, 498)
' The font to draw the text
Dim F as New Font ("Microsoft Ya-Black", fontstyle.underline)
' Text content
Dim str as String = Textbox5.text
' Create an object to draw an image
Dim g as Graphics = Graphics.fromimage (bitmap)
' The coordinates of the line
Dim x1, x2, y1, y2, s1, S2 as Integer
X1 = CType (TextBox1.Text, Integer)
x2 = CType (TextBox2.Text, Integer)
Y1 = CType (TextBox3.Text, Integer)
y2 = CType (Textbox4.text, Integer)
' The coordinates of the text
S1 = CType (Textbox6.text, Integer)
S2 = CType (Textbox7.text, Integer)
' Limit the scope of the drawing
G.drawimage (IMG, 0, 0, 343, 498)
' Draw text
g.DrawString (str, F, brushes.red, S1, S2)
' Draw line
G.drawline (pens.white, x1, x2, y1, y2)
' Save path after drawing is complete
Dim iimg as String = "~/upload/11.jpg"
Dim img1 as String = Server.MapPath (iimg)
' JPG image quality parameters
Dim EP as Imaging.encoderparameters = New imaging.encoderparameters
' Image quality value
Ep. Param (0) = New imaging.encoderparameter (Imaging.Encoder.Quality, CLng (Textbox8.text))
' Read the image content in streaming mode
Dim codecs as imaging.imagecodecinfo () = Imaging.ImageCodecInfo.GetImageEncoders
Dim ici as Imaging.imagecodecinfo
For each codec as Imaging.imagecodecinfo in codecs
If codec. MimeType = "Image/jpeg" Then
ICI = Codec
End If
Next
' Save the Painted image.
Bitmap. Save (IMG1, ICI, EP)
Image1.imageurl = iimg
' Release object
G.dispose ()
Bitmap. Dispose ()
Img. Dispose ()