MakeTiff.vb
  1. ''
  2. '' This code is part of Document Solutions for Imaging demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports System.Collections.Generic
  8. Imports System.Linq
  9. Imports System.Numerics
  10. Imports GrapeCity.Documents.Drawing
  11. Imports GrapeCity.Documents.Text
  12. Imports GrapeCity.Documents.Imaging
  13.  
  14. '' This sample loads several JPEG images and combines them
  15. '' into a single multi-frame TIFF.
  16. Public Class MakeTiff
  17. Function GenerateImageStream(
  18. ByVal targetMime As String,
  19. ByVal pixelSize As Size,
  20. ByVal dpi As Single,
  21. ByVal opaque As Boolean,
  22. Optional sampleParams As String() = Nothing) As Stream
  23.  
  24. If Not targetMime = MimeTypes.TIFF Then
  25. Throw New Exception("This sample only supports TIFF output format.")
  26. End If
  27.  
  28. Dim sources As String() =
  29. {
  30. Path.Combine("Resources", "Images", "colosseum.jpg"),
  31. Path.Combine("Resources", "Images", "lady.jpg"),
  32. Path.Combine("Resources", "Images", "minerva.jpg"),
  33. Path.Combine("Resources", "Images", "forum.jpg")
  34. }
  35.  
  36. Dim ms = New MemoryStream()
  37. Using tw = New GcTiffWriter(ms)
  38. For Each src In sources
  39. Using bmp = New GcBitmap(src)
  40. tw.AppendFrame(bmp)
  41. End Using
  42. Next
  43. End Using
  44. ms.Seek(0, SeekOrigin.Begin)
  45. Return ms
  46. End Function
  47.  
  48. Public ReadOnly Property DefaultMime() As String
  49. Get
  50. Return MimeTypes.TIFF
  51. End Get
  52. End Property
  53. End Class
  54.