Hi,
We are facing average of 5.5 seconds time consumption while converting an Image with size(17712, 24792) into ImageSource. Kindly check the below code snippet and please suggest me how to reduce the time consumption?
private void ImageToImageSource_Click(object sender, RoutedEventArgs e)
{
ImageSource imgsource = null;
System.Drawing.Image image = new System.Drawing.Bitmap(17712, 24792);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(image);
graphics.FillRectangle(System.Drawing.Brushes.White, new System.Drawing.Rectangle(0, 0, (int)(image.Width), (int)(image.Height)));
Stopwatch sw = new Stopwatch();
sw.Start();
using (Stream ms = new MemoryStream())
{
image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
var decoder = BitmapDecoder.Create(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
imgsource = decoder.Frames[0];
}
sw.Stop();
Debug.WriteLine("Elapsed: " + sw.ElapsedMilliseconds.ToString());
}
Regards,
Divya