Setting the compression when creating the multipage Tif files in Vb.net

I

Ira

I was successful in creating the multipage Tif files in VB.net using
the following the following code:

Public Sub SaveSeveralOnePageFilesInADir(ByVal DrNm As String, ByVal

resultFl As String)


Dim pages As Bitmap = Nothing
Dim PgCnt As Integer
Dim ix As Integer


Dim fl As String


If Dir$(resultFl) <> "" Then
Kill(resultFl)
End If


'---------------------------------


Dim enc As System.Drawing.Imaging.Encoder =
System.Drawing.Imaging.Encoder.SaveFlag


Dim info As System.Drawing.Imaging.ImageCodecInfo =
Nothing


For Each ice As System.Drawing.Imaging.ImageCodecInfo In
System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders


If ice.MimeType = "image/tiff" Then


info = ice


End If


Next


Dim ep As System.Drawing.Imaging.EncoderParameters =
New System.Drawing.Imaging.EncoderParameters(1)


fl = Dir$(DrNm + "\*.*", FileAttribute.Normal +
FileAttribute.Archive)
ix = 0
Do While fl <> ""
fl = UCase$(fl)
If InStr(fl, ".JPG") <> 0 Or InStr(fl, ".GIF") <> 0 Then
ix = ix + 1
fl = DrNm + "\" + fl
If ix = 1 Then


ep.Param(0) = New
System.Drawing.Imaging.EncoderParameter(enc,
CType(System.Drawing.Imaging.EncoderValue.MultiFrame, Long))


pages = Image.FromFile(fl)
pages.Save(resultFl, info, ep)
Else
ep.Param(0) = New
System.Drawing.Imaging.EncoderParameter(enc,
CType(System.Drawing.Imaging.EncoderValue.FrameDimensionPage, Long))


Dim bm As Bitmap = Image.FromFile(fl)
pages.SaveAdd(bm, ep)
End If
End If
fl = Dir$()
Loop


ep.Param(0) = New
System.Drawing.Imaging.EncoderParameter(enc,
CType(System.Drawing.Imaging.EncoderValue.Flush, Long))


pages.SaveAdd(ep)


End Sub


My big problem now is that I was not able to find information on how I
can
also set the compression that I need for the pages of those multipage
Tif
files. For example, for the black and white images in a multipage Tiff
file,
the compression should be CCITT4, and, for the color images in a
multipage
Tif file, the compression should be JPEG medium compression with the
medium
resolution. How can it be accomplished?


Thank you very much.


Irene S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top