VB.Net by API/System.Drawing.Imaging/EncoderParameter — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:50, 26 мая 2010
New EncoderParameter
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing.Imaging
public class MainClass
public Shared Sub Main
Dim imgCodecInfo As ImageCodecInfo = Nothing
Dim encoder As Encoder = Nothing
Dim encoderParam As EncoderParameter = Nothing
Dim encoderParams As New EncoderParameters(3)
Dim curBitmap As New Bitmap("yourfile.jpg")
Dim mimeType As String = "image/tiff"
Dim encoders() As ImageCodecInfo
encoders = ImageCodecInfo.GetImageEncoders()
Dim i As Integer
While i < encoders.Length
If encoders(i).MimeType = mimeType Then
imgCodecInfo = encoders(i)
End If
End While " Set color depth to 24 pixels
encoder = encoder.ColorDepth
encoderParam = New EncoderParameter(encoder, CLng(EncoderValue.rupressionLZW))
encoderParams.Param(0) = encoderParam
encoder = encoder.rupression
encoderParam = New EncoderParameter(encoder, CLng(EncoderValue.rupressionLZW))
encoderParams.Param(1) = encoderParam
encoder = encoder.Transformation
encoderParam = New EncoderParameter(encoder, CLng(EncoderValue.TransformRotate180))
encoderParams.Param(2) = encoderParam
curBitmap.Save("newFile.tif", imgCodecInfo, encoderParams)
curBitmap.Dispose()
End Sub
End class