Let's scroll an image

2 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2012-02-18 19:55
Let's scroll an image

Hello,

i've loaded an image into a window (blitted with compositing).

Now, how to scroll the image in a desidered direction?
Moreover, the image can be larger than the window itself and can i pan the image in various direction?

whose
whose's picture
Offline
Last seen: 6 years 5 months ago
Joined: 2011-08-09 02:25
I don´t know how you used

I don´t know how you used CompositeTags() this time, but I presume you used it "the simple way" (no triangles).

Well, as you "blitted" your image into your window, you could do it a second (and third and fourth...) time. If you adjust the start coordinates according to the desired scroll direction, the impression of "scrolling" will result. If you want to scroll right, increase the x-coordinate (coordinate´s going to the "right" of the image). If you want to scroll left, decrease it. Similar for scrolling down and up.

If you use this method, it´s a good idea to use an image larger than the window´s visible size. Otherwise the CompositeTags() function would try to blit things that might not belong to your process memory or it would blit garbage.

Panning is a bit more complex, as, for classic blitting, the image to blit could be e.g. separated into pieces. Two should be enough to make a full round. This depends on the window´s visible size.

You blit with "scroll offset" (per image piece) then. As you sroll to the "end" of the image, the pieces will swap in blitting order (in the beginning, you blit piece 1, then piece 2. As soon as panning occurs, you will blit piece 2 first, then piece 1).

There are several other methods, e.g. image tiling (so the image "tiles" are blitted as needed for the scrolling/panning).

Just do some experiments and remember, that CompositeTags() blits rectangles, as long as you don´t use the vertex (triangle) mode.

Coder Insane-Software

www.insane-software.de

Log in or register to post comments