WPF crash with large image. HRESULT 0x88980406

0

I have a UserControl that is really wide 60 x 50,000 which is displaying the waveform of an audio file. Several users are reporting a crash with an hresult of 0x88980406 and the googles isn't giving any useful information about it. The app is using .Net 4.0.

        if (mainCanvas.Children.Count > 0)
            mainCanvas.Children.Clear();

        for (int i = 0; i < CurrentSong.waveformLines.Length; i++)
        {
            mainCanvas.Children.Add(CurrentSong.waveformLines[i]);
        }

        RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)Width, (int)Height, 96d, 96d, PixelFormats.Pbgra32);

        // needed otherwise the image output is black 
        mainCanvas.Measure(new Size((int)Width, (int)Height));
        mainCanvas.Arrange(new Rect(new Size((int)Width, (int)Height)));
        renderBitmap.Render(mainCanvas);

        Image img = new Image();
        img.Source = renderBitmap;

        if (mainCanvas.Children.Count > 0)
            mainCanvas.Children.Clear();
        mainCanvas.Children.Add(img);

What I'm doing is drawing the sample values as line segments and then adding them all to an array and put them on the canvas. Then I create a bitmap from the canvas, delete all the line segments and then add the bitmap as the source of an Image control back on to the canvas.

it crashes in mainCanvas.Children.Add(img);

wpf
image
canvas
asked on Stack Overflow Feb 19, 2013 by Carse O'Mighty • edited Feb 19, 2013 by Carse O'Mighty

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0