Analysis on adding watermarks to Images Using ASP. NET (VB)

Source: Internet
Author: User

ASP. NET (VB) adds watermark text to the image: Specifies the image to add watermark text

 
 
  1. DimimgAsImage = Image. FromFile (Server. MapPath ("~ /Upload/1.jpg"))
  2. 'Create a bitmap object for drawing operations. You cannot directly operate on a format other than BMP, maybe) 
  3. DimbitmapAsNewBitmap (343,498)
  4. 'Specifies the font of the text to be drawn. 
  5. DimfAsNewFont ("", 16, FontStyle. Underline)
  6. 'Text content 
  7. DimstrAsString = TextBox5.Text
  8. 'Create an object for image plotting 
  9. DimgAsGraphics = Graphics. FromImage (bitmap)
  10. 'Line Coordinate 
  11. Dimx1, x2, y1, y2, s1, s2AsInteger
  12. X1 =CType(TextBox1.Text,Integer)
  13. X2 =CType(TextBox2.Text,Integer)
  14. Y1 =CType(TextBox3.Text,Integer)
  15. Y2 =CType(TextBox4.Text,Integer)
  16. 'Text Coordinate 
  17. S1 =CType(TextBox6.Text,Integer)
  18. S2 =CType(TextBox7.Text,Integer)
  19. 'Specifies the drawing range. 
  20. G. DrawImage (img, 343,498)
  21. 'Draw text 
  22. G. DrawString (str, f, Brushes. Red, s1, s2)
  23. 'Draw a line 
  24. G. DrawLine (Pens. White, x1, x2, y1, y2)
  25. 'Save path after painting 
  26. DimiimgAsString ="~ /Upload/11.jpg" 
  27. Dimimg1AsString = Server. MapPath (iimg)
  28. 'Jpg image quality parameters 
  29. DimepAsImaging. EncoderParameters = NewImaging. EncoderParameters
  30. 'Image Quality Value 
  31. Ep. Param (0) = NewImaging. EncoderParameter (Imaging. Encoder. Quality,CLng(TextBox8.Text ))
  32. 'Reading image content as a stream 
  33. DimcodecsAsImaging. ImageCodecInfo () = Imaging. ImageCodecInfo. GetImageEncoders
  34. DimiciAsImaging. ImageCodecInfo
  35. ForEachcodecAsImaging. ImageCodecInfoIncodecs
  36. Ifcodec. MimeType ="Image/jpeg"Then 
  37. Ici = codec
  38. EndIf
  39. Next 
  40. 'Save the drawn Image 
  41. Bitmap. Save (img1, ici, ep)
  42. Image1.ImageUrl = iimg
  43. 'Release the object 
  44. G. Dispose ()
  45. Bitmap. Dispose ()
  46. Img. Dispose ()

This section describes how to add watermark text to images of ASP. NET (VB) applications. We hope this will help you.

  1. Analysis of ASP. NET annotations
  2. Analysis on the use of ASP. NET trace
  3. Application of ASP. NET trace in page execution
  4. Introduction to ASP. NET Request Object Attributes
  5. Analysis on the use of ASP. NET Request objects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.