Load a TIFF from a byte array in C#

TIFF

To load a TIFF image from a byte array, use the CreateGdPictureImageFromByteArray method of the GdPictureImaging class. This creates a new GdPicture representation of the image, and it returns the unique image identifier (imageID) of the newly created GdPicture image. This method accepts the following parameters:

  • Data — The image data stored in a byte array.
  • ImageFormat — Optional: A member of the DocumentFormat enumeration that specifies the image format.

When you no longer need an image resource and the System.Drawing.Bitmap object, release them with the ReleaseGdPictureImage and Dispose methods.

To load a TIFF image from a byte array, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from a TIFF image.
byte[] byteaArray = File.ReadAllBytes(@"C:\temp\source.tif");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);