WPF more efficient Render() Visual/Control to a bitmap

Is there more efficient way to render a visual to a bitmap? I am trying to use shader effects on UI elements and then I want to modify the result in code pixel-by-pixel. Now I use something like this:

        Button btn = new Button();
        btn.Effect = new BlurEffect();
        RenderTargetBitmap rbmp = new RenderTargetBitmap(64, 64, 96d, 96d, PixelFormats.Pbgra32);
        rbmp.Render(btn); // this is very slow
        byte[] pixels = new byte[64 * 64 * 4];
        int str = width * PixelFormats.Pbgra32.BitsPerPixel / 8;
        rbmp.CopyPixels(pixels, str, 0);

Is there any way to get these pixels of post-processed Button into array without using slow rendering used in RenderTargetBitmap?


Ok, I found an answer... It is impossible :/ There is currently a request for MS to implement hardware accelerated rendering for RenderTargetBitmap but in my opinion MS is not willing to do this. Case closed :(

链接地址: http://www.djcxy.com/p/26878.html

上一篇: RenderTargetBitmap和DPI

下一篇: WPF效率更高()可视化/控制到位图