Wednesday, 15 July 2015

c# - GDI+ Generic Error, multple frame tiff, multiple image formats -



c# - GDI+ Generic Error, multple frame tiff, multiple image formats -

i have seen many issues involving gdi+ generic error, have not seen particular matter raised before. consistently getting error, on windows systems other windows 8, when attempting read (system.drawing.image.selectactiveframe) multiple-frame tiff includes frames in mixed photometric interpretation formats. say, file includes both rgb color , min-is-white formats, corresponding differences in bits/sample , samples/pixel frame parameters. error consistently raising frame encountered format different of first frame.

// convert file .tiff .pdf static void convertfile(string file, string pdffilename) { string localmessage = string.empty; seek { //if it's pdf renamed , go on if (file.tolower().contains(".pdf")) { file.copy(file, pdffilename); return; } // if file exists homecoming if (file.exists(pdffilename)) { return; } using (var stream = new filestream(pdffilename, filemode.create)) { localmessage = "01"; var document = new itextsharp.text.document(); localmessage = "01"; var author = itextsharp.text.pdf.pdfwriter.getinstance(document, stream); localmessage = "02"; var bm = bitmap.fromfile(file); localmessage = "03"; var total = bm.getframecount(framedimension.page); localmessage = "04"; document.open(); //itextsharp.text.pdf.pdfcontentbyte cb = writer.directcontent; localmessage = "05"; itextsharp.text.image img = null; (var currentframe = 0; currentframe < total; ++currentframe) { localmessage = "06=>" + currentframe.tostring(); bm.selectactiveframe(framedimension.page, currentframe); localmessage = "07=>" + currentframe.tostring(); img = itextsharp.text.image.getinstance(bm, imageformat.bmp); localmessage = "08=>" + currentframe.tostring(); img.scalepercent(72f / img.dpix * 100); localmessage = "09=>" + currentframe.tostring(); img.setabsoluteposition(0, 0); localmessage = "10=>" + currentframe.tostring(); itextsharp.text.rectangle pagerect = new itextsharp.text.rectangle(0, 0, img.scaledwidth, img.scaledheight); localmessage = "11=>" + currentframe.tostring(); document.setpagesize(pagerect); localmessage = "12=>" + currentframe.tostring(); document.newpage(); localmessage = "13=>" + currentframe.tostring(); document.add(img); } localmessage = "14"; bm.dispose(); localmessage = "15"; document.close(); localmessage = "16"; stream.close(); } } grab (exception exception) { string msg = exception.message + "\r\n" + "coversion error--\r\n" + "\tinput file name: " + file + "\r\n" + "\toutput file name: " + pdffilename + "\r\n" + "\tlocal message" + localmessage + "\r\n"; console.writeline(msg); saveerror(msg); throw; } }

the "local message" "06=>n", n 0-based index of frame transitions new format.

does know why happening or how prepare it?

c# .net gdi+ tiff

No comments:

Post a Comment