how to divide a gif image into pieces
raja peter

hi all,

I want to divide a gif image with 4*4(16), 3*3(9),etc parts.

Thank you

Ceagon Xylas

Be more specific.

I'm guessing you want tiles... I'm also having to assume you are already using a library that can load gifs into Allegro, and that you want to divide the image into diffrent parts inside of your program (as opposed to storing them as a file/files.

raja peter

exactly ceagon

I used algif library and load_gif() fn. i want to divide that image into a no of pieces which on the whole constitute the original image.

Thank You

Ceagon Xylas

Okay, first off, you're going to need an array of bitmaps. You can then store each tile to its individual bitmap.

BITMAP *tile[64];
for(int i=0; i<64; i++)

Then you have to decide how you want to rip the segments of the image to the bitmaps themselves. I rip them in a row going left to right. Like this: image1vy6.gif

BITMAP *g=load_gif();
const int tile_width=16;
const int tile_height=16; 
for(int i=0; i<g->w/tile_width; i++) //decides how many tiles it can squeeze out of the bitmap

So now the blue tile (tile 0 in the image) is stored in tile[0].

I'll warn you, I didn't compile any of that. So there may be some errors. But this is the theory behind it.

raja peter


Thread #588196. Printed from