To preview the scanned TIFF document, I currently use the following:
Bitmap bmp = new Bitmap(@"document.tif");
var ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Png);
var bmpBytes = ms.GetBuffer();
bmp.Dispose();
ms.Close();
return new FileStreamResult(new MemoryStream(bmpBytes), "image/png");
Is there a way to speed up the conversion? Using something other than the standard Image.Save () method?
I found an unsafe class that locks and unlocks bitmapData between pixel manipulations here , but I'm not sure if it is suitable for my task (because I only need to convert from one format to another). However, my profiler shows about 30 ms gain (up to 116 ms, after 83 ms)
source
share