MissingLink
Member
- Joined
- Feb 20, 2009
- Messages
- 7
- Programming Experience
- 3-5
Hi there
I have a system that scans in images to multi page tiff files and allows the user to preview before finalising. When the user previews, they click on the page number which should then use the TiffBitmapDecoder to read that particular frame in from the Tiff file and display the BitmapSource in an Image control...this works just fine. The problem comes in when they scan another page which is then inserted into the tiff file. The tiff file is returning that it cannot be accessed as another process is using it. How do I get the TiffBitmapDecoder to release the Tiff file?
Code to generate preview:
Code to insert page into tiff:
I have a system that scans in images to multi page tiff files and allows the user to preview before finalising. When the user previews, they click on the page number which should then use the TiffBitmapDecoder to read that particular frame in from the Tiff file and display the BitmapSource in an Image control...this works just fine. The problem comes in when they scan another page which is then inserted into the tiff file. The tiff file is returning that it cannot be accessed as another process is using it. How do I get the TiffBitmapDecoder to release the Tiff file?
Code to generate preview:
VB.NET:
Public ReadOnly Property GetPagePreview(ByVal intPage As Integer) As BitmapSource
Get
Dim bitmapSource As BitmapSource
Try
Dim p As Integer = (mCurrentDocumentIndex + 1)
Dim path As New Uri("temp\" & p.ToString & "\" & p.ToString & ".tiff", UriKind.Relative)
Dim decoder As New TiffBitmapDecoder(path, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
bitmapSource = decoder.Frames(intPage)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Return bitmapSource
End Get
End Property
Code to insert page into tiff:
VB.NET:
Dim strDoc As String = "temp\" & (mCurrentDocumentIndex + 1).ToString & "\" & _
(mCurrentDocumentIndex + 1).ToString
aFinishScanParts.ImageBox.InsertTIF(strDoc & ".tiff", strDoc & ".tiff", aFinishScanParts.IntPageIndex + 1)