none
I am getting insufficient memory exception when i am trying to render a image(10000 X 10000) resolution with canvas(10000 X 10000) resolution. RRS feed

  • Question

  • dc.PushTransform(new TranslateTransform(difX + left - horizontalScale, difY + top - verticalScale));
                        dc.PushTransform(new ScaleTransform(1, 1));
    
                        // Ask canvas to draw overlays
                        drawingCanvas.Draw(dc);
    
                        // Restore old actual scale.
                        drawingCanvas.ActualScale = oldActualScale;
    
                        // Restore clip
                        drawingCanvas.RefreshClip();
    
                        dc.Pop();
                        dc.Pop();
                        dc.Pop();
    
                        dc.Close();
                        width = (Utilityhelper.GetDIPIndependentHorizontal(rect.Width));
                        height = (Utilityhelper.GetDIPIndependentVertical(rect.Height));
    
                        bmp = new RenderTargetBitmap((int)width, (int)(height), Utilityhelper.graphics.DpiX, Utilityhelper.graphics.DpiY, PixelFormats.Default);
                        if (bmp != null)
                        {
                            bmp.Render(vs);
                        }
    Friday, November 28, 2014 1:29 PM

All replies


  • Hello Ankur tripathi,

    It seems the image you want to render is too large so that you get this error.(You haven't mentioned how large the imagewill be, the size may too huge for your application.) What about use DecodePixelWidth & DecodePixelHeight to get round the problem?

    Sample here: http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.decodepixelwidth(v=vs.110).aspx

    Regards,



    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 1, 2014 7:56 AM
    Moderator
  • hey

    thankx for replying the image size is around 10000 X 10000 i do not want to resize it... is there a way to render this kind of image with canvas ....

    Monday, December 1, 2014 10:22 AM
  • @Ankur tripathi,

    Here are some methods to increate the WPF image render:

    http://mrpfister.com/programming/increasing-wpf-rendering-performance-2/

    Caching Brushes

    Reducing Image Footprint

    Opacity

    Store as Content not as a Resource

    Use JPGs instead of PNGs

    You can try these except the second one, you have reject the solution.

    Best regards,

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.




    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 24, 2014 2:04 AM
    Moderator