Tiff Encoder : Tiff « 2D Graphics « VB.Net Tutorial






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.CompressionLZW))
        encoderParams.Param(0) = encoderParam

        encoder = encoder.Compression
        encoderParam = New EncoderParameter(encoder, CLng(EncoderValue.CompressionLZW))
        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








17.69.Tiff
17.69.1.Create Tiff file
17.69.2.Tiff Encoder