RappyFood Posted January 30, 2008 Posted January 30, 2008 I have written a simple app to take a collection of single-frame tiff images from file and combine them to a single multi-frame tiff. It works fine. Unfortunately, the multi-frame tiff is saved with LZW compression. This app is meant to support an older process which can only read files with CCITT 4 compression. My source code follows. Irrelevant code is removed for clarity. It saves a multi-frame tiff with LZW compression. Does anybody know how I can save a multi-frame tif with CCITT 4 compression? I am using Visual Studio 2005 with .NET Framework 2.0 Private Sub MergeTifsWorker( _ ByVal SourceTifs As Collection, _ ByVal SaveName As String, _ ByVal AsyncOp As AsyncOperation) Dim masterbm As Bitmap Dim bm As Bitmap Dim exc As Exception = Nothing Try masterbm = _ CType(Bitmap.FromFile(SourceTifs.Item(1).ToString), Bitmap) Dim enc As Encoder = Encoder.SaveFlag Dim info As ImageCodecInfo = GetEncoderInfo("image/tiff") Dim ep As New EncoderParameters(1) ep.Param(0) = _ New EncoderParameter(enc, CLng(EncoderValue.MultiFrame)) masterbm.Save(SaveName, info, ep) ep.Param(0) = _ New EncoderParameter( _ enc, CLng(EncoderValue.FrameDimensionPage)) For i As Integer = 2 To fileCount bm = CType(Bitmap.FromFile(SourceTifs.Item(i).ToString), Bitmap) masterbm.SaveAdd(bm, ep) Next ep.Param(0) = _ New EncoderParameter(enc, CLng(EncoderValue.Flush)) masterbm.SaveAdd(ep) Catch ex As Exception exc = ex End Try .... Irrelevant code removed End Sub Regards, RappyFood Quote
RappyFood Posted February 1, 2008 Author Posted February 1, 2008 Once more, with syntax highlighting. RappyFood [vbnet] Private Sub MergeTifsWorker( _ ByVal SourceTifs As Collection, _ ByVal SaveName As String, _ ByVal AsyncOp As AsyncOperation) Dim masterbm As Bitmap Dim bm As Bitmap Dim exc As Exception = Nothing Try masterbm = _ CType(Bitmap.FromFile(SourceTifs.Item(1).ToString), Bitmap) Dim enc As Encoder = Encoder.SaveFlag Dim info As ImageCodecInfo = GetEncoderInfo("image/tiff") Dim ep As New EncoderParameters(1) ep.Param(0) = _ New EncoderParameter(enc, CLng(EncoderValue.MultiFrame)) masterbm.Save(SaveName, info, ep) ep.Param(0) = _ New EncoderParameter( _ enc, CLng(EncoderValue.FrameDimensionPage)) For i As Integer = 2 To fileCount bm = CType(Bitmap.FromFile(SourceTifs.Item(i).ToString), Bitmap) masterbm.SaveAdd(bm, ep) Next ep.Param(0) = _ New EncoderParameter(enc, CLng(EncoderValue.Flush)) masterbm.SaveAdd(ep) Catch ex As Exception exc = ex End Try 'Irrelevant code removed End Sub [/vbnet] Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.