I am able to convert a single page TIFF to a PNG in .Net, however, how would I do this for a multipage TIFF?
Complete example without the need for 3'rd party assemblies:
' MAIN CODE '
Dim ImageBitmap = Bitmap.FromStream(ImageStream)
Dim FrameCount = ImageBitmap.GetFrameCount(FrameDimension.Page)
Dim RunningHeight As Integer = 0
Dim MaxWidth As Integer = 0
For MeasurementFrameIndex As Integer = 0 To FrameCount - 1
ImageBitmap.SelectActiveFrame(FrameDimension.Page, MeasurementFrameIndex)
RunningHeight += ImageBitmap.Height
MaxWidth = Math.Max(MaxWidth, ImageBitmap.Width)
Next
Dim CombinedBitmap As New Bitmap(MaxWidth, RunningHeight)
Dim RunningVerticalPosition As Integer = 0
For CombinationFrameIndex As Integer = 0 To FrameCount - 1
ImageBitmap.SelectActiveFrame(FrameDimension.Page, CombinationFrameIndex)
EmbedBitmap(ImageBitmap, CombinedBitmap, RunningVerticalPosition)
RunningVerticalPosition += ImageBitmap.Height + 1
Next
' SUPPORT ROUTINES '
Private Shared Sub EmbedBitmap(
SourceBitmap As Bitmap,
ByRef DestinationBitmap As Bitmap,
VerticalPosition As Integer)
Dim SourceRectangle As New Rectangle(
New Point(0, 0),
New Size(SourceBitmap.Width, SourceBitmap.Height))
Dim DestinationRectangle As New Rectangle(
New Point(0, VerticalPosition),
New Size(SourceBitmap.Width, SourceBitmap.Height))
Using Canvas As Graphics = Graphics.FromImage(DestinationBitmap)
Canvas.DrawImage(
SourceBitmap,
DestinationRectangle,
SourceRectangle,
GraphicsUnit.Pixel)
End Using
End Sub