问题
On client side I have image in TIFF images with multiple pages.
Firt I convert this image file to byte array and then I sent this data to web service.
For converting TIFF to byte array I use method System.IO.File.ReadAllBytes
.
On web service side I would like convert this byte array to If byte array contains invalid data it will be nice to have som control.
Then I need do these things:
parse all pages from multi TIFF image to objects type of
System.Drawing.Image
get specified images from multi TIFF
convert
BitMiracle.LibTiff.Classic.Tiff
object to byte arraysave
BitMiracle.LibTiff.Classic.Tiff
object to disk in TIFF format
I google it, tried many samples but for me is bit problem convert byte array to
BitMiracle.LibTiff.Classic.Tiff
(and back) and convert BitMiracle.LibTiff.Classic.Tiff
object which hold multi TIFF to
collection of System.Drawing.Image
.
回答1:
There are two samples that show how to create System.Drawing.Image
from a TIFF
- Convert color TIFF to a 32-bit System.Drawing.Bitmap
- Convert color TIFF to a 24-bit System.Drawing.Bitmap
These samples create System.Drawing.Image
for the current page of a TIFF. By default, current page is the first page.
In case your TIFF image is multipage you still can use the code from samples. But you will need to encapsulate the code in a method and call that method multiple times: one time for each page.
The number of pages can be retrieved using NumberOfDirectories method. Current page can be set using SetDirectory method.
The How to use a System.IO.Stream to read or write TIFF images sample shows how to read TIFF image from a memory stream.
来源:https://stackoverflow.com/questions/12122976/converting-tiff-obect-from-bitmiracle-libtiff-to-net-types