-void blit(unsigned char *src_img, const Rect &src_rect, unsigned char* dest_img,
- const Rect &dest_rect, int dest_x, int dest_y)
-{
- int width = src_rect.width;
- int height = src_rect.height;
-
- int xoffs = dest_x - dest_rect.x;
- if(xoffs < 0) {
- dest_x = dest_rect.x;
- width += xoffs;
- }
-
- int yoffs = dest_y - dest_rect.y;
- if(yoffs < 0) {
- dest_y = dest_rect.y;
- height += yoffs;
- }
-
- int xend = dest_x + width;
- if(xend >= dest_rect.width) {
- width -= xend - dest_rect.width;
- }
-
- int yend = dest_y + height;
- if(yend >= dest_rect.height) {
- height -= yend - dest_rect.height;
- }