By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.GetImageEnco ders
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.MultiFra me, 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.FrameDim ensionPage, 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.

Feb 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

http://www.bobpowell.net/generating_multipage_tiffs.htm

Ken
------------
"Ira" <ir*****@ifat.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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.GetImageEnco ders
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.MultiFra me, 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.FrameDim ensionPage, 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.

Feb 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.