I've been using the following code as part of a migration process:
var decoder = new LfiBitmapDecoder(reportImage, BitmapCreateOptions.None); var encoder = new LfiBitmapEncoder(LfiContainerFormat.Tiff); foreach (var frame in decoder.Frames.ToList()) { LfiBitmapSource source = new LfiWriteableBitmap(frame.DecodeBitmap()); var bw = new LfiGrayscaleThresholdBitmap(source, BITONAL_THRESHOLD); var newFrame = new LfiBitmapFrame(bw, LfiBitmapCodec.FaxGroup4); encoder.Frames.Add(newFrame); }
I periodically get the following:
OR
OR very rarely
I don't know if the above code is the proper way to do what I'm attempting. Basically, I had some legacy data that is in an old database. I've converted it into reports that I download as TIFFs from SSRS. The problem with the images that come from SSRS is that they have RGB subpixel rendering and need to be smashed down to black and white. They are also multi-page files. I played around and came up with the above code to correct those issues. I can include more if needed.
Is the error that I'm seeing a result of me using the SDK libraries incorrectly, or is something else going on? It's definitely not consistent. If I run the process multiple times, it will not trip up on the same document each time. I just did a run of 150 documents, and got the error 27 times.