PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

help needed: XY -scrolling

Hi,
I'm trying to make small demo where I can scroll both (x,y) directions. I have read Phantoms tutorial4 (thanks!), but I cannot make work nice xy scrolling. (my oroginal image in largebuffer is about 1600x1600 big).  Does it have to be 240xsomething?? Can somebody throw some advice or piece of code?
Thanks in advance,
srontti
Hi,

If you want to scroll a 1600x1600 bitmap, you can do this like this:

- First, read the entire bitmap:

Code:

PIXEL* map = new PIXEL[1600*1600];
tgaload( MAPFILE, 1600, 1600, map);


- Then, when you want to display it:
Basically, you want to copy 320 lines of 240 pixels from this map to your display buffer. This can be done like this:

Code:

PIXEL* src = map + x + y * 1600;
PIXEL* dst = getbuffer();
for ( int y = 0; y < 320; y++ )
{
 memcpy( dst, src, 240 );
 dst += 240;
 src += 1600;
}


Make sure you don't scroll off the map, this could result in a crash.

- Jacco.
thank you, It works now!
/srontti