PSyMastR
\m/O__O\m/
So, I loaded a surface in, that contains a whole bunch of images, for example, a tilesheet. Now, I want to split every tile into its own surface. What is the correct way to chop it up?
CODE
SDL_surface *temp = SDL_SetClipRect(old_surface, some_rect);
Now, does that work at all, or does SDL_SetClipRect just change the clipping of the rectangle to old_surface? And, if it changes the rect of the old surface, then does it also delete image data out of the bounds as well, or does it just keep a bunch of massive surfaces with smaller rects?
Also, what would be the correct way of doing this?
Currently, I am stuck at this point:
CODE
SDL_Surface *tiles_temp = load_image("some_image_png_or_bmp.png");
//A nice place to store all the tile images
std::vector<SDL_Surface*> tiles;
SDL_Rect load_tiles_rect;
load_tiles_rect.w = TILE_SIZE;
load_tiles_rect.h = TILE_SIZE;
for(int tile_load_x = 0; tile_load_x <= (tiles_temp->w - TILE_SIZE); tile_load_x += TILE_SIZE)
{
for(int tile_load_y = 0; tile_load_y <= (tiles_temp->h - TILE_SIZE); tile_load_y += TILE_SIZE)
{
load_tiles_rect.x = tile_load_x;
load_tiles_rect.y = tile_load_y;
tiles.push_back(/* WHAT GOES IN HERE */);
}
}
CODE
SDL_surface *temp = SDL_SetClipRect(old_surface, some_rect);
Now, does that work at all, or does SDL_SetClipRect just change the clipping of the rectangle to old_surface? And, if it changes the rect of the old surface, then does it also delete image data out of the bounds as well, or does it just keep a bunch of massive surfaces with smaller rects?
Also, what would be the correct way of doing this?
Currently, I am stuck at this point:
CODE
SDL_Surface *tiles_temp = load_image("some_image_png_or_bmp.png");
//A nice place to store all the tile images
std::vector<SDL_Surface*> tiles;
SDL_Rect load_tiles_rect;
load_tiles_rect.w = TILE_SIZE;
load_tiles_rect.h = TILE_SIZE;
for(int tile_load_x = 0; tile_load_x <= (tiles_temp->w - TILE_SIZE); tile_load_x += TILE_SIZE)
{
for(int tile_load_y = 0; tile_load_y <= (tiles_temp->h - TILE_SIZE); tile_load_y += TILE_SIZE)
{
load_tiles_rect.x = tile_load_x;
load_tiles_rect.y = tile_load_y;
tiles.push_back(/* WHAT GOES IN HERE */);
}
}