Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...