Domanda

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 array

  • save 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.Tiffobject which hold multi TIFF to collection of System.Drawing.Image.

È stato utile?

Soluzione

There are two samples that show how to create System.Drawing.Image from a TIFF

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top