public static void Run()
{
// ExStart:ExtractTIFFFramesToBMPImageFormat
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();
using (TiffImage multiImage = (TiffImage)Image.Load(dataDir + "SampleTiff1.tiff"))
{
// Create an instance of int to keep track of frames in TiffImage
int frameCounter = 0;
// Iterate over the TiffFrames in TiffImage
foreach (TiffFrame tiffFrame in multiImage.Frames)
{
multiImage.ActiveFrame = tiffFrame;
// Load Pixels of TiffFrame into an array of Colors
Color[] pixels = multiImage.LoadPixels(tiffFrame.Bounds);
// Create an instance of bmpCreateOptions
BmpOptions bmpCreateOptions = new BmpOptions();
bmpCreateOptions.BitsPerPixel = 24;
// Set the Source of bmpCreateOptions as FileCreateSource by specifying the location where output will be saved
bmpCreateOptions.Source = new FileCreateSource(string.Format("{0}\\ConcatExtractTIFFFramesToBMP_out{1}.bmp", dataDir, frameCounter), false);
// Create a new bmpImage
using (BmpImage bmpImage = (BmpImage)Image.Create(bmpCreateOptions, tiffFrame.Width, tiffFrame.Height))
{
// Save the bmpImage with pixels from TiffFrame
bmpImage.SavePixels(tiffFrame.Bounds, pixels);
bmpImage.Save();
}
frameCounter++;
}
}
// ExEnd:ExtractTIFFFramesToBMPImageFormat
}
}