ASP. NET (VB) adds watermark text to the image: Specifies the image to add watermark text
- DimimgAsImage = Image. FromFile (Server. MapPath ("~ /Upload/1.jpg"))
- 'Create a bitmap object for drawing operations. You cannot directly operate on a format other than BMP, maybe)
- DimbitmapAsNewBitmap (343,498)
- 'Specifies the font of the text to be drawn.
- DimfAsNewFont ("", 16, FontStyle. Underline)
- 'Text content
- DimstrAsString = TextBox5.Text
- 'Create an object for image plotting
- DimgAsGraphics = Graphics. FromImage (bitmap)
- 'Line Coordinate
- Dimx1, x2, y1, y2, s1, s2AsInteger
- X1 =CType(TextBox1.Text,Integer)
- X2 =CType(TextBox2.Text,Integer)
- Y1 =CType(TextBox3.Text,Integer)
- Y2 =CType(TextBox4.Text,Integer)
- 'Text Coordinate
- S1 =CType(TextBox6.Text,Integer)
- S2 =CType(TextBox7.Text,Integer)
- 'Specifies the drawing range.
- G. DrawImage (img, 343,498)
- 'Draw text
- G. DrawString (str, f, Brushes. Red, s1, s2)
- 'Draw a line
- G. DrawLine (Pens. White, x1, x2, y1, y2)
- 'Save path after painting
- DimiimgAsString ="~ /Upload/11.jpg"
- Dimimg1AsString = Server. MapPath (iimg)
- 'Jpg image quality parameters
- DimepAsImaging. EncoderParameters = NewImaging. EncoderParameters
- 'Image Quality Value
- Ep. Param (0) = NewImaging. EncoderParameter (Imaging. Encoder. Quality,CLng(TextBox8.Text ))
- 'Reading image content as a stream
- DimcodecsAsImaging. ImageCodecInfo () = Imaging. ImageCodecInfo. GetImageEncoders
- DimiciAsImaging. ImageCodecInfo
- ForEachcodecAsImaging. ImageCodecInfoIncodecs
- Ifcodec. MimeType ="Image/jpeg"Then
- Ici = codec
- EndIf
- Next
- 'Save the drawn Image
- Bitmap. Save (img1, ici, ep)
- Image1.ImageUrl = iimg
- 'Release the object
- G. Dispose ()
- Bitmap. Dispose ()
- Img. Dispose ()
This section describes how to add watermark text to images of ASP. NET (VB) applications. We hope this will help you.
- Analysis of ASP. NET annotations
- Analysis on the use of ASP. NET trace
- Application of ASP. NET trace in page execution
- Introduction to ASP. NET Request Object Attributes
- Analysis on the use of ASP. NET Request objects