MakeTiff.vb
''
'' This code is part of Document Solutions for Imaging demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports System.Collections.Generic
Imports System.Linq
Imports System.Numerics
Imports GrapeCity.Documents.Drawing
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Imaging

'' This sample loads several JPEG images and combines them
'' into a single multi-frame TIFF.
Public Class MakeTiff
    Function GenerateImageStream(
                ByVal targetMime As String,
                ByVal pixelSize As Size,
                ByVal dpi As Single,
                ByVal opaque As Boolean,
                Optional sampleParams As String() = Nothing) As Stream

        If Not targetMime = MimeTypes.TIFF Then
            Throw New Exception("This sample only supports TIFF output format.")
        End If

        Dim sources As String() =
            {
                Path.Combine("Resources", "Images", "colosseum.jpg"),
                Path.Combine("Resources", "Images", "lady.jpg"),
                Path.Combine("Resources", "Images", "minerva.jpg"),
                Path.Combine("Resources", "Images", "forum.jpg")
            }

        Dim ms = New MemoryStream()
        Using tw = New GcTiffWriter(ms)
            For Each src In sources
                Using bmp = New GcBitmap(src)
                    tw.AppendFrame(bmp)
                End Using
            Next
        End Using
        ms.Seek(0, SeekOrigin.Begin)
        Return ms
    End Function

    Public ReadOnly Property DefaultMime() As String
        Get
            Return MimeTypes.TIFF
        End Get
    End Property
End Class