ImageToByte function take an array of bytes for each page of a multipage tiff. The purpose of this is to create a single page tiff that contains all pages of the original tiff.
My code works perfectly except with tiffs with compression ccitt t.6. When I pass every page of this multipage tiff to ImageToByte function, it returns me a byte array corresponding to a completely black image.
Private Function ImageToByte(bImagen As System.Drawing.Image) As Byte()
Dim codec As ImageCodecInfo = GetEncoderInfo("image/tiff")
Dim enc As Encoder = System.Drawing.Imaging.Encoder.SaveFlag
Dim ep As New EncoderParameters(2)
ep.Param(0) = New EncoderParameter(enc, EncoderValue.FrameDimensionPage)
ep.Param(1) = New EncoderParameter(Encoder.Compression, EncoderValue.CompressionNone)
Using ms As New MemoryStream
bImagen.Save(ms, codec, ep)
ImageToByte = ms.ToArray
End Using
End Function
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
Could someone tell me how to fix this issue?