WriteableBitmap Shift

Apr 28, 2011 at 10:34 PM

I am new to using WriteableBitmap. 

I am able to update the WriteableBitmap to show data.  But I am stumped on how to shift a writeableBitmap to the right by one cell.

After shifting over once cell, I am going to add a new column on the left and of course have thrown away the last column on the right.

Is there a good book or reference site that has more documentation on WriteableBitmap.

I am trying to use CopyPixel and WritePixel.  But WritePixel gives me an execution error:  Value does not fall within the expected range

here is the code I am trying to run:

_writeableBitmapItem.CopyPixels (new Int32Rect( 0, 0, (int)(Width - 1), (int)Height), buffer, _writeableBitmapItem.BackBufferStride - 1, 0);

_writeableBitmapItem.WritePixels (new Int32Rect ( 1, 0, (int)(Width), (int)Height), buffer, _writeableBitmapItem.BackBufferStride, 0);

Can anyone offer a suggestion?


Sep 23, 2013 at 9:42 PM
Edited Sep 23, 2013 at 9:43 PM
For a WPF project, I used 3 writeablebitmaps and the Blit method to accomplish something similar in an overridden OnRender method.
  1. First, I crop the original writeablebitmap, "wbm" and make that the source of a new one, "croppedWBM" with the new size and destination (I just move it over by the amount clipped).
  2. Then I create a third, "addWBM" which has the position and size of the new area I want to add.
  3. Finally, I clear the original and use it to Blit "croppedWBM" and "addWBM" together.
This method allows me to be able to write new data to the new section while maintaining the original data (minus the part that was cropped). OnRender is called every second making it appear that the image is moving horizontally, in my case to the left.