MakeTiff.cs
//
// This code is part of Document Solutions for Imaging demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Drawing;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Imaging;

namespace DsImagingWeb.Demos
{
    // This sample loads several JPEG images and combines them
    // into a single multi-frame TIFF.
    public class MakeTiff
    {
        public string DefaultMime { get => Common.Util.MimeTypes.TIFF; }

        public Stream GenerateImageStream(string targetMime, Size pixelSize, float dpi, bool opaque, string[] sampleParams = null)
        {
            if (targetMime != Common.Util.MimeTypes.TIFF)
                throw new Exception("This sample only supports TIFF output format.");

            var sources = new 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"),
            };

            var ms = new MemoryStream();
            using (var tw = new GcTiffWriter(ms))
            {
                foreach (var src in sources)
                    using (var bmp = new GcBitmap(src))
                        tw.AppendFrame(bmp);
            }
            ms.Seek(0, SeekOrigin.Begin);
            return ms;
        }
    }
}