Scrolling a WriteableBitmap
- by Skoder
I need to simulate my background scrolling but I want to avoid moving my actual image control. Instead, I'd like to use a WriteableBitmap and use a blitting method. What would be the way to simulate an image scrolling upwards? I've tried various things buy I can't seem to get my head around the logic:
//X pos, Y pos, width, height
Rect src = new Rect(0, scrollSpeed , 480, height);
Rect dest = new Rect(0, 700 - scrollSpeed , 480, height);
//destination rect, source WriteableBitmap, source Rect, blend mode
wb.Blit(destRect, wbSource, srcRect, BlendMode.None);
scrollSpeed += 5;
if (scrollSpeed > 700) scrollSpeed = 0;
If height is 10, the image is quite fuzzy and moreso if the height is 1. If the height is a taller, the image is clearer, but it only seems to do a one to one copy. How can I 'scroll' the image so that it looks like it's moving up in a continuous loop? (The height of the screen is 700).