Funny, I coded some functions for the same topic yesterday. This is what I came up with:
Code:
BMAP* bmap_clone (BMAP* src)
{
   // no source?
   if (src == NULL)
      return(NULL);
      
   var format = bmap_lock(src, 0);
   
   // invalid bitmap or unknown format?
   if (format == 0)
      return(NULL);
   else  
      bmap_unlock(src);
   
   BMAP* r = bmap_createblack(src->width, src->height, format);
   
   if (r != NULL)
      bmap_copy(src, r);
   
   return(r);
}

BMAP* bmap_copy (BMAP* src, BMAP* dest)
{
   if ((src == NULL) || (dest == NULL))
      return(NULL);
   
   bmap_blit(dest, src, NULL, NULL);
   
   return(dest);
}


Using the format retrieved by bmap_lock in bmap_createblack is actually safe. The manual says about bmap_createblack:
Quote:
format - bitmap format (uncompressed formats only; see bmap_lock) or number of bits per pixel (8, 16, 24, 32).

I'm not 100% sure, if a bmap_process approach would be faster - but from what I believe and know, it will smile. Maybe someone has the time to write a generic function for that?