3
我写了一个代码来将单个tiff文件合并到多页面tiff中。但输出在最后带有空白页。代码工作正常,如果输入文件是黑色的&白色但不适用于彩色的.tiff文件。例如,如果我给100个文件,并作为输入输出单个tiff文件拿出47页,其余的是空白的。多页面tiff程序空白页面
我使用标准代码来实现此功能,以下是我的代码。任何人知道为什么
using (FileStream fs = new FileStream(fileNameTemp, FileMode.Append, FileAccess.Write))
{
System.Windows.Media.Imaging.TiffBitmapEncoder tifEnc = new System.Windows.Media.Imaging.TiffBitmapEncoder();
tifEnc.Compression = System.Windows.Media.Imaging.TiffCompressOption.Default;
foreach (string fileName1 in filePaths)
{
Console.WriteLine("FileName:::" + fileName1);
System.Windows.Media.Imaging.BitmapImage bmpImg = new System.Windows.Media.Imaging.BitmapImage();
bmpImg.BeginInit();
bmpImg.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad;
bmpImg.UriSource = new Uri(fileName1);
bmpImg.EndInit();
System.Windows.Media.Imaging.FormatConvertedBitmap fcb = new System.Windows.Media.Imaging.FormatConvertedBitmap(bmpImg,
System.Windows.Media.PixelFormats.Rgb24,
System.Windows.Media.Imaging.BitmapPalettes.Halftone27,
1.0);
tifEnc.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(fcb));
}
tifEnc.Save(fs);
fs.Dispose();
}
在此先感谢!