It would probably be a better idea to keep the tileset editing outside of the program you're doing. Are you really in need of a limited palette of colors as well?
The common approach to doing something like this is to just use a big tileset bitmap, and the indices on your 2-dimensional array that represent the "map" are used to represent what tile needs to be drawn. For example, from this RPG Maker tileset (48x48 tiles):
The code to calculate the coordinates to crop out of the tileset depending on the "index" of each cell in the 2D Map:
int t=map_data[x][y];
...
int cx, cy;
cx = (t % TILESET_WIDTH) * REAL_TILE_W;
cy = (t / TILESET_WIDTH) * REAL_TILE_H;
TILESET_WIDTH (12 in this example) being the max number of tiles that can fit in the width of this tileset, and REAL_TILE_W and REAL_TILE_H being 48 and 48 in this case.
t is the index stored in each your 2D map cells. You can use this to calculate the coordinates of which part of the tileset you should render as a 48x48 tile on this case on the screen. To render them on screen, all you have to do is calculate which are the visible tiles on screen depending on where your camera's placed at, and iterate through the 2D dimensional array in those ranges. There's some more efficient ways to go about this, but this should be very easy to understand.
Notice that most of what I said here would be done in real-time while rendering the map, the only thing that would need to be set up beforehand is just the 2D Dimensional map array with indices, and load the tileset somehow. I assume you're already using some sort of library for this. If not, I recommend looking into either
SDL or
Allegro 5. Saving and loading the 2D Map as indices to a file should be super simple to do.
You might want to extend this whole 2D Map thing to have different layers as well (RPG Maker uses 3 and it tends to work on most cases). You'll likely need to place tiles that are background only, tiles that are props above the background but not above the player, and tiles that are above everything else.
This post has been edited by Dario FF: 13 February 2014 - 10:15 AM