MakeTiff.vb
''
'' This code is part of GrapeCity Documents for Imaging samples.
'' Copyright (c) GrapeCity, 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 targetEncoding As ImageEncoding,
                Optional pixelWidth As Integer = 1024,
                Optional pixelHeight As Integer = 1024,
                Optional opaque As Boolean = True,
                Optional dpiX As Single = 96,
                Optional dpiY As Single = 96) As Stream

        If Not targetEncoding = ImageEncoding.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", "rome.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 DefaultEncoding() As ImageEncoding
        Get
            Return ImageEncoding.Tiff
        End Get
    End Property
End Class