MakeTiff.cs
  1. //
  2. // This code is part of Document Solutions for Imaging demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using GrapeCity.Documents.Drawing;
  11. using GrapeCity.Documents.Text;
  12. using GrapeCity.Documents.Imaging;
  13.  
  14. namespace DsImagingWeb.Demos
  15. {
  16. // This sample loads several JPEG images and combines them
  17. // into a single multi-frame TIFF.
  18. public class MakeTiff
  19. {
  20. public string DefaultMime { get => Common.Util.MimeTypes.TIFF; }
  21.  
  22. public Stream GenerateImageStream(string targetMime, Size pixelSize, float dpi, bool opaque, string[] sampleParams = null)
  23. {
  24. if (targetMime != Common.Util.MimeTypes.TIFF)
  25. throw new Exception("This sample only supports TIFF output format.");
  26.  
  27. var sources = new string[]
  28. {
  29. Path.Combine("Resources", "Images", "colosseum.jpg"),
  30. Path.Combine("Resources", "Images", "lady.jpg"),
  31. Path.Combine("Resources", "Images", "minerva.jpg"),
  32. Path.Combine("Resources", "Images", "forum.jpg"),
  33. };
  34.  
  35. var ms = new MemoryStream();
  36. using (var tw = new GcTiffWriter(ms))
  37. {
  38. foreach (var src in sources)
  39. using (var bmp = new GcBitmap(src))
  40. tw.AppendFrame(bmp);
  41. }
  42. ms.Seek(0, SeekOrigin.Begin);
  43. return ms;
  44. }
  45. }
  46. }
  47.