多页TIFF转换成PNG净转换成、多页、TIFF、PNG

2023-09-03 02:09:02 作者:淡淡伤゛微微凉

我能够在单页TIFF转换成.NET中PNG,不过,我将如何做到这一点的一个多页TIFF?

I am able to convert a single page TIFF to a PNG in .Net, however, how would I do this for a multipage TIFF?

推荐答案

您应该选择在一个循环中有效帧(页),每个TIFF页面转换为PNG。

You should select active frame (page) in a loop and convert each tiff page to a png.

int pageCount = 1;
try
{
    pageCount = bmp.GetFrameCount(FrameDimension.Page);
}
catch (Exception)
{
    // sometimes GDI+ throws internal exceptions.
    // just ignore them.
}

for (int page = 0; page < pageCount; page++)
{
    bmp.SelectActiveFrame(FrameDimension.Page, page);
    // save or otherwise process tiff page
}

这code假定您可以在System.Drawing.Bitmap对象加载的TIFF图像。

This code assumes that you can load Tiff image in System.Drawing.Bitmap object.