TizzyT

SaveJPEG Quality Property

Sep 4th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.71 KB | None | 0 0
  1.     Private Sub SaveJpeg(ByVal IMG As Bitmap, ByVal Path As String, ByVal Quality As Byte)
  2.         Dim jpgEncoder As ImageCodecInfo = Nothing
  3.         Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders()
  4.         For Each codec As ImageCodecInfo In codecs
  5.             If codec.FormatID = ImageFormat.Jpeg.Guid Then jpgEncoder = codec
  6.         Next
  7.         Dim myEncoder As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.Quality
  8.         Dim myEncoderParameters As New EncoderParameters(1)
  9.         Dim myEncoderParameter As New EncoderParameter(myEncoder, Quality)
  10.         myEncoderParameters.Param(0) = myEncoderParameter
  11.         IMG.Save(Path, jpgEncoder, myEncoderParameters)
  12.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment