通过使用以下代码将当前所有图片保存为tiff文件时出错。
循环批量保存图片,在保存的过程中,有时保存到40张的时候出错,有时保存到70张的时候出错。
错误提示:not able to open file
错识提示代码处:codecs.Save(image, ouputFileName, RasterImageFormat.TifLzw, image.BitsPerPixel, 1, 1, -1, CodecsSavePageMode.Append);
源代码:
- DocumentReader reader = DocumentReader.Create(textBox1.Text, new DocumentReaderLoadOptions() { Resolution = 300});
- if (reader != null && reader.Pages != null && reader.Pages.Count > 0)
- {
- int pos = 1;
- foreach (var page in reader.Pages)
- {
- this.Text = pos.ToString();
- if (pos == 1)
- {
- using (RasterImage image = reader.ImageManager.GetPageImage(page))
- {
- using (RasterCodecs codecs = new RasterCodecs())
- {
- codecs.Save(image, ouputFileName, RasterImageFormat.TifLzw, image.BitsPerPixel);
- }
-
- }
- }
- else
- {
- using (RasterImage image = reader.ImageManager.GetPageImage(page))
- {
- using (RasterCodecs codecs = new RasterCodecs())
- {
- codecs.Save(image, ouputFileName, RasterImageFormat.TifLzw, image.BitsPerPixel, 1, 1, -1, CodecsSavePageMode.Append);
- }
-
- }
- }
- pos++;
- }
- }
复制代码 |
|