I am hoping to be able to view .Tif files in my vb.net application - is there a component that can be used to do that. I've been messing around with Tiff Viewer but for some reason the file is stretched beyond anything - you can barely make out what it says. I tried to adjust the width of the viewer but it did not do much, it is still stretched horizontally.
Asked
Active
Viewed 1,489 times
2
-
Have you tried to set his size properties to adjust to fullscreen, zoom, etc? – Juanche Mar 07 '17 at 20:06
-
@JuanJoséDiazYoris what component? I tried with tiff viewier but there's not much online to help me with it – BobSki Mar 07 '17 at 20:07
-
i thought that you are showing it in a pictureBox encoding - decoding. Please look at this: https://msdn.microsoft.com/es-es/library/system.windows.media.imaging.tiffbitmapdecoder(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 and https://msdn.microsoft.com/es-es/library/aa969817(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 – Juanche Mar 07 '17 at 20:15
1 Answers
2
Based on https://stackoverflow.com/a/401579/741136, this will load a multiframe tif into a collection of single frames:
Function LoadTif(filename As String) As List(Of Image)
Dim lstTif As New List(Of Image)
Dim bmp As Bitmap = DirectCast(Image.FromFile(filename), Bitmap)
For i As Integer = 0 To bmp.GetFrameCount(Imaging.FrameDimension.Page) - 1
bmp.SelectActiveFrame(Imaging.FrameDimension.Page, i)
Dim ms As New System.IO.MemoryStream
bmp.Save(ms, Imaging.ImageFormat.Tiff)
lstTif.Add(Image.FromStream(ms))
ms.Dispose()
Next i
Return lstTif
End Function