Im sure you could probably get this code to do the job you want

But I would suggest looking at my suggestion in your other sprite thread first.
Code:
#ifndef bmap_slice_c
#define bmap_slice_c
/////////////////////////////////////////////////////////////////////////////////////////
//
//		BMAP_SLICE.C
//			Function to take a 3DGS compatible image file(SourceName) and slice it into an
//			array of BMP's of chosen size(Out_Width by Out_Height), and save them
//			to a chosen folder(TargetName[path \\ delimited]), with a chosen filename
//			prefix(end of TargetName) with a numeric representation of its array index.
//			[NOTE] Out_Width/Height MUST be a 'power of eight' number. (8,16,32,etc)
//			Returns 'true' if sucsessful, 'false' if an error occured.
//		Created :    05-01-2009
//		Includes:   None
//
/////////////////////////////////////////////////////////////////////////////////////////
////
////
function bmap_slice(STRING* SourceName, STRING* TargetName, var Out_Width, var Out_Height)
{
   BMAP* SourceBMP = NULL;		SourceBMP = bmap_create(SourceName);
   if(SourceBMP==NULL)	return(0);										//Source File Not Found
   //
   var T_Width  = integer(SourceBMP.width  / Out_Width ) + 1;   
   var Width_Name_Length  = str_len(str_for_int(NULL, T_Width ));  
   if(T_Width<8)	{	ptr_remove(SourceBMP);	return(0);	}		//Target Width below min
   //
   var T_Height = integer(SourceBMP.height / Out_Height)+1;   
   var Height_Name_Length = str_len(str_for_int(NULL, T_Height));
   if(T_Height<8)	{	ptr_remove(SourceBMP);	return(0);	}		//Target Height below min
   BMAP*	TargetBMP = NULL;		VECTOR tmpV0, tmpV1;
   STRING*	BuildName = "";	STRING* SaveName = "";
   //
   int xx,yy;   for(yy=0; yy<T_Height; yy++)   for(xx=0; xx<T_Width; xx++)
   {
      str_cpy(SaveName, TargetName);
      str_cpy(BuildName, "");   
         str_cat_num(BuildName, "0000000000%.0f", xx);
         str_clip(BuildName, (str_len(BuildName) - Width_Name_Length));
      str_cat(SaveName, BuildName);      str_cat(SaveName, "_");
      str_cpy(BuildName, "");   
         str_cat_num(BuildName, "0000000000%.0f", yy);
         str_clip(BuildName, (str_len(BuildName) - Height_Name_Length));
      str_cat(SaveName, BuildName);      str_cat(SaveName, ".bmp");
      if(TargetBMP!=NULL)   bmap_remove(TargetBMP);
      TargetBMP = bmap_createblack(Out_Width,Out_Height,(SourceBMP.bytespp*8));
      vec_set(tmpV0, vector(xx*Out_Width,yy*Out_Height,0));
      vec_set(tmpV1, vector(Out_Width,Out_Height,0));
      bmap_blitpart(TargetBMP, SourceBMP, NULL, NULL, tmpV0, tmpV1);   
      bmap_save(TargetBMP, SaveName);
   }
   ptr_remove(SourceBMP);   ptr_remove(TargetBMP);   
   ptr_remove(BuildName);   ptr_remove(SaveName);
   return(1);   //sucessful.
}
//
#endif   //bmap_slice_c




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial