Wpf: Why is WriteableBitmap getting slower?

Posted by fritz on Stack Overflow See other posts from Stack Overflow or by fritz
Published on 2010-04-23T19:37:38Z Indexed on 2010/04/23 19:43 UTC
Read the original article Hit count: 683

Filed under:
|

There is a simple MSDN example about WriteableBitmap.

It shows how to draw a freehand line with the cursor by just updating one pixel when the mouse is pressed and is moving over a WPF -Image Control.

 writeableBitmap.Lock();  
 (...set the writeableBitmap.BackBuffers pixel value...)
 writeableBitmap.AddDirtyRect(new Int32Rect(column, row, 1, 1));
 writeableBitmap.Unlock();

Now I'm trying to understand the following behaviour when moving the mouse pointer very fast:

If the image/bitmap size is relatively small e.g. 800:600 pixel, then the last drawn pixel is always "synchronized" with the mouse pointers position, i.e. there is no delay, very fast reaction on mouse movements.

But if the bitmap gets larger e.g. 1300:1050 pixel, you can notice a delay, the last drawn pixel always appear a bit delayed behind the moving mouse pointer.

So as in both cases only one pixel gets updated with "AddDirtyRect", the reaction speed should be independent from the bitmap size!? But it seems that Writeablebitmap gets slower when it's size gets larger.

Or does the whole bitmap somehow get transferred to the graphic device on every writeableBitmap.Unlock(); call , and not only the rectangle area speficied in the AddDirtyRect method?

fritz

© Stack Overflow or respective owner

Related posts about wpf

Related posts about writeablebitmap