So I have an app that walks directories and creates multipage tiffs based on what the directory is named. They're named with a 3 letter prefix _ a random number. I'm trying to create the multipage tiff named with the 3 letter prefix. Here is my code:
The line that's red is the line thats erroring out. I think its because I'm trying to load the image, then save to that same place. I'm not really sure how to fix this problem. Anyone have any ideas on how I could fix this?
Oh, this sub is called on every iteration of the loop when it finds a tiff.
I almost forgot to add this, each folder has 1 singlepage tiff in it. And there can be multiple folders with the same 3 letter prefix in a directory, hence why I'm looping this and checking the docType variables.
VB.NET:
Private Sub appendTiffs(ByVal p_OutputPath As String, ByVal p_Tiff As String, ByVal p_docType As String)
Dim tiff As Image = Image.FromFile(p_Tiff)
MasterBitmap = New Bitmap(tiff.Width, tiff.Height, PixelFormat.Format1bppIndexed)
For Each ice As ImageCodecInfo In ImageCodecInfo.GetImageEncoders
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next
ep.Param(0) = New EncoderParameter(enc, CType(EncoderValue.MultiFrame, Long))
If p_docType <> oldDocType Then
MasterBitmap = CType(tiff, Bitmap)
MasterBitmap.Save(p_OutputPath & "\" & p_docType & ".tif", info, ep)
MasterBitmap.Dispose()
Else
MasterBitmap = CType(Image.FromFile(p_OutputPath & "\" & p_docType & ".tif"), Bitmap)
[COLOR="Red"]MasterBitmap.Save(p_OutputPath & "\" & p_docType & ".tif", info, ep)[/COLOR]
ep.Param(0) = New EncoderParameter(enc, CType(EncoderValue.FrameDimensionPage, Long))
MasterBitmap.SaveAdd(CType(Image.FromFile(p_Tiff), Bitmap), ep)
ep.Param(0) = New EncoderParameter(enc, CType(EncoderValue.Flush, Long))
MasterBitmap.SaveAdd(ep)
End If
oldDocType = p_docType
tiff.Dispose()
End Sub
The line that's red is the line thats erroring out. I think its because I'm trying to load the image, then save to that same place. I'm not really sure how to fix this problem. Anyone have any ideas on how I could fix this?
Oh, this sub is called on every iteration of the loop when it finds a tiff.
I almost forgot to add this, each folder has 1 singlepage tiff in it. And there can be multiple folders with the same 3 letter prefix in a directory, hence why I'm looping this and checking the docType variables.
Last edited: