Hello,
I'm having troubles with saving a tiff-file with a certain compression
and colordepth. This is the code I use:
----------------------------------------------------------------------
private sub MakeTiff
dim imgSource as new bitmap(strTifSo urceFile)
Dim TiffCodecInfo As System.Drawing. Imaging.ImageCo decInfo
Dim CompressionEnco der As System.Drawing. Imaging.Encoder
Dim Params As System.Drawing. Imaging.Encoder Parameters
Dim myencoder As System.Drawing. Imaging.Encoder
myencoder = System.Drawing. Imaging.Encoder .ColorDepth
Dim myImageCodecInf o As System.Drawing. Imaging.ImageCo decInfo
myImageCodecInf o = GetEncoderInfo
(System.Drawing .Imaging.ImageF ormat.Tiff)
Dim format As System.Drawing. Imaging.ImageFo rmat
Dim Index As Integer
'Get the CodecInfo for TIFF format
TiffCodecInfo = GetEncoderInfo
(System.Drawing .Imaging.ImageF ormat.Tiff)
'Colordepth
Dim myEncoderParame terColor As New
System.Drawing. Imaging.Encoder Parameter(myenc oder, 24L)
'Compression
CompressionEnco der = System.Drawing. Imaging.Encoder .Compression
Dim myEncoderParame terCompression = New
System.Drawing. Imaging.Encoder Parameter(Compr essionEncoder, CLng
(System.Drawing .Imaging.Encode rValue.Compress ionLZW))
'Create an EncoderParamete rs object.
Params = New System.Drawing. Imaging.Encoder Parameters(2)
Params.Param(0) = myEncoderParame terCompression
Params.Param(1) = myEncoderParame terColor
imgSource.Save( "c:\test.ti f", TiffCodecInfo, Params)
end sub
Private Function GetEncoderInfo( ByVal format As
System.Drawing. Imaging.ImageFo rmat) As
System.Drawing. Imaging.ImageCo decInfo
Dim index As Integer
Dim encoders() As System.Drawing. Imaging.ImageCo decInfo
encoders = System.Drawing. Imaging.ImageCo decInfo.GetImag eEncoders()
For index = 0 To (encoders.Lengt h - 1)
If UCase(encoders( index).FormatDe scription) = UCase
(format.ToStrin g) Then
Return encoders(index)
End If
Next index
End Function
-----------------------------------------------------------------
I can set the colordepth in this part:
'Colordepth
Dim myEncoderParame terColor As New
System.Drawing. Imaging.Encoder Parameter(myenc oder, 24L)
I can set the compression in this part:
'Compression
CompressionEnco der = System.Drawing. Imaging.Encoder .Compression
Dim myEncoderParame terCompression = New
System.Drawing. Imaging.Encoder Parameter(Compr essionEncoder, CLng
(System.Drawing .Imaging.Encode rValue.Compress ionLZW))
PROBLEM:
The Tif-source file is a 475kb file 200dpi, black and white. I want to
save a rotated version of this tif-file, same size, same dpi, same
colors. I can;t get it done.
(1) I can't set the colordepth to less then 24L. When I do this I get an
error in the GDI+. I would like to have a Tif-file with a colordepth
of 1 bit. Is this possible?
(2) When setting the compression to CompressionLZW or CompressionNone it
works fine. But I can;t select the other compressions. When I do so I
also get an error.
--
Met vriendelijke groet / With regards / Saludos,
Moviat Automatisering
Maurice Mertens
mauricem@moviat _KillSpamWordFo rEMail.nl
tel: +31 162 470 534
fax: +31 162 470 502
I'm having troubles with saving a tiff-file with a certain compression
and colordepth. This is the code I use:
----------------------------------------------------------------------
private sub MakeTiff
dim imgSource as new bitmap(strTifSo urceFile)
Dim TiffCodecInfo As System.Drawing. Imaging.ImageCo decInfo
Dim CompressionEnco der As System.Drawing. Imaging.Encoder
Dim Params As System.Drawing. Imaging.Encoder Parameters
Dim myencoder As System.Drawing. Imaging.Encoder
myencoder = System.Drawing. Imaging.Encoder .ColorDepth
Dim myImageCodecInf o As System.Drawing. Imaging.ImageCo decInfo
myImageCodecInf o = GetEncoderInfo
(System.Drawing .Imaging.ImageF ormat.Tiff)
Dim format As System.Drawing. Imaging.ImageFo rmat
Dim Index As Integer
'Get the CodecInfo for TIFF format
TiffCodecInfo = GetEncoderInfo
(System.Drawing .Imaging.ImageF ormat.Tiff)
'Colordepth
Dim myEncoderParame terColor As New
System.Drawing. Imaging.Encoder Parameter(myenc oder, 24L)
'Compression
CompressionEnco der = System.Drawing. Imaging.Encoder .Compression
Dim myEncoderParame terCompression = New
System.Drawing. Imaging.Encoder Parameter(Compr essionEncoder, CLng
(System.Drawing .Imaging.Encode rValue.Compress ionLZW))
'Create an EncoderParamete rs object.
Params = New System.Drawing. Imaging.Encoder Parameters(2)
Params.Param(0) = myEncoderParame terCompression
Params.Param(1) = myEncoderParame terColor
imgSource.Save( "c:\test.ti f", TiffCodecInfo, Params)
end sub
Private Function GetEncoderInfo( ByVal format As
System.Drawing. Imaging.ImageFo rmat) As
System.Drawing. Imaging.ImageCo decInfo
Dim index As Integer
Dim encoders() As System.Drawing. Imaging.ImageCo decInfo
encoders = System.Drawing. Imaging.ImageCo decInfo.GetImag eEncoders()
For index = 0 To (encoders.Lengt h - 1)
If UCase(encoders( index).FormatDe scription) = UCase
(format.ToStrin g) Then
Return encoders(index)
End If
Next index
End Function
-----------------------------------------------------------------
I can set the colordepth in this part:
'Colordepth
Dim myEncoderParame terColor As New
System.Drawing. Imaging.Encoder Parameter(myenc oder, 24L)
I can set the compression in this part:
'Compression
CompressionEnco der = System.Drawing. Imaging.Encoder .Compression
Dim myEncoderParame terCompression = New
System.Drawing. Imaging.Encoder Parameter(Compr essionEncoder, CLng
(System.Drawing .Imaging.Encode rValue.Compress ionLZW))
PROBLEM:
The Tif-source file is a 475kb file 200dpi, black and white. I want to
save a rotated version of this tif-file, same size, same dpi, same
colors. I can;t get it done.
(1) I can't set the colordepth to less then 24L. When I do this I get an
error in the GDI+. I would like to have a Tif-file with a colordepth
of 1 bit. Is this possible?
(2) When setting the compression to CompressionLZW or CompressionNone it
works fine. But I can;t select the other compressions. When I do so I
also get an error.
--
Met vriendelijke groet / With regards / Saludos,
Moviat Automatisering
Maurice Mertens
mauricem@moviat _KillSpamWordFo rEMail.nl
tel: +31 162 470 534
fax: +31 162 470 502
Comment