本文整理匯總了VB.NET中System.Drawing.Imaging.Encoder.Compression字段的典型用法代碼示例。如果您正苦於以下問題:VB.NET Encoder.Compression字段的具體用法?VB.NET Encoder.Compression怎麽用?VB.NET Encoder.Compression使用的例子?那麽, 這裏精選的字段代碼示例或許可以為您提供幫助。
在下文中一共展示了Encoder.Compression字段的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example_SetTIFFCompression
' 導入命名空間
Imports System.Drawing
Imports System.Drawing.Imaging
Class Example_SetTIFFCompression
Public Shared Sub Main()
Dim myBitmap As Bitmap
Dim myImageCodecInfo As ImageCodecInfo
Dim myEncoder As Encoder
Dim myEncoderParameter As EncoderParameter
Dim myEncoderParameters As EncoderParameters
' Create a Bitmap object based on a BMP file.
myBitmap = New Bitmap("Shapes.bmp")
' Get an ImageCodecInfo object that represents the TIFF codec.
myImageCodecInfo = GetEncoderInfo("image/tiff")
' Create an Encoder object based on the GUID
' for the Compression parameter category.
myEncoder = Encoder.Compression
' Create an EncoderParameters object.
' An EncoderParameters object has an array of EncoderParameter
' objects. In this case, there is only one
' EncoderParameter object in the array.
myEncoderParameters = New EncoderParameters(1)
' Save the bitmap as a TIFF file with LZW compression.
myEncoderParameter = New EncoderParameter(myEncoder, Fix(EncoderValue.CompressionLZW))
myEncoderParameters.Param(0) = myEncoderParameter
myBitmap.Save("ShapesLZW.tif", myImageCodecInfo, myEncoderParameters)
End Sub
Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
Dim j As Integer
Dim encoders() As ImageCodecInfo
encoders = ImageCodecInfo.GetImageEncoders()
j = 0
While j < encoders.Length
If encoders(j).MimeType = mimeType Then
Return encoders(j)
End If
j += 1
End While
Return Nothing
End Function 'GetEncoderInfo
End Class