Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created September 25, 2015 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/c8063eb007d22e99894e to your computer and use it in GitHub Desktop.
Save bjoerntx/c8063eb007d22e99894e to your computer and use it in GitHub Desktop.
/***************************************************************
* SplitMultipageTIFF method
* description: Splits a multipage TIFF into separate images
*
* param: image - the image path
* return val: A list of images
***************************************************************/
private List<Image> SplitMultipageTIFF(string image)
{
List<Image> listImages = new List<Image>();
Bitmap bmp = (Bitmap)Image.FromFile(image);
int iCount = bmp.GetFrameCount(FrameDimension.Page);
for (int i = 0; i < iCount; i++)
{
// store each frame
bmp.SelectActiveFrame(FrameDimension.Page, i);
MemoryStream byteStream = new MemoryStream();
bmp.Save(byteStream, ImageFormat.Tiff);
// assemble new image
listImages.Add(Image.FromStream(byteStream));
}
return listImages;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment