Hi All I've the following code for taking a small "tile" from a larger graphic and placing it to the screen:
the main picture is 15x5 tiles of 20x20px each
this code works..ish. the correct tile is pulled from the main graphic, and placed to the screen etc, BUT, it''s mmm um well wrong.... what I get is:
the first 5 rasters upside down, then the next 5 upside down, then next upside down etc...
so instead of the rasters looking like:
1
2
3
4
5
6
7
8
9
10
they look like
5
4
3
2
1
10
9
8
7
6
etc.... I't completly got me stumped..... given that its doing it in rasters of 5, I though it could somehow relate to the fact that the main image is 5 tiles in the y axis...anyhow HELP!
- Code:
void place_item(int destsizex, int xpos, int ypos, int xsize, int ysize, int number_itemsx, int item, PIXEL* src, PIXEL* dest)
{
unsigned int dest_loc = (destsizex * ypos) + xpos;
unsigned int source_width = number_itemsx * xsize;
unsigned int source_loc = ((item / number_itemsx) * source_width * ysize) +
((item % number_itemsx) * xsize);
for (int y = 0; y < ysize; y++)
{
for (int x = 0; x < xsize; x++)
{
dest[dest_loc + x] = src[source_loc + x];
}
dest_loc += destsizex; // move down a row in dest
source_loc += source_width; // move down a row in source
}
}
the main picture is 15x5 tiles of 20x20px each
this code works..ish. the correct tile is pulled from the main graphic, and placed to the screen etc, BUT, it''s mmm um well wrong.... what I get is:
the first 5 rasters upside down, then the next 5 upside down, then next upside down etc...
so instead of the rasters looking like:
1
2
3
4
5
6
7
8
9
10
they look like
5
4
3
2
1
10
9
8
7
6
etc.... I't completly got me stumped..... given that its doing it in rasters of 5, I though it could somehow relate to the fact that the main image is 5 tiles in the y axis...anyhow HELP!