less wankly
This commit is contained in:
		
							parent
							
								
									740b8d0363
								
							
						
					
					
						commit
						ea96b298b3
					
				
					 1 changed files with 20 additions and 30 deletions
				
			
		
							
								
								
									
										50
									
								
								src/image.c
									
										
									
									
									
								
							
							
						
						
									
										50
									
								
								src/image.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -499,26 +499,19 @@ static void tile_copy(cammy_image *dest,
 | 
			
		|||
    size_t x,
 | 
			
		||||
           y;
 | 
			
		||||
 | 
			
		||||
    for (y=0; y < from->height; y++) {
 | 
			
		||||
        if (to->y + y > dest->height) {
 | 
			
		||||
    for (y=from->y; y<from->y + from->height; y++) {
 | 
			
		||||
        if (y > dest->height) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (x=0; x < from->width; x++) {
 | 
			
		||||
            uint8_t value = tile_read((cammy_tile *)src->buf,
 | 
			
		||||
                                      from->x + x,
 | 
			
		||||
                                      from->y + y,
 | 
			
		||||
                                      src->width);
 | 
			
		||||
        for (x=from->x; x<from->x + from->width; x++) {
 | 
			
		||||
            uint8_t value = tile_read((cammy_tile *)src->buf, x, y, src->width);
 | 
			
		||||
 | 
			
		||||
            if (to->x + x > dest->width) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            tile_write((cammy_tile *)dest->buf,
 | 
			
		||||
                       to->x + x,
 | 
			
		||||
                       to->y + y,
 | 
			
		||||
                       dest->width,
 | 
			
		||||
                       value);
 | 
			
		||||
            tile_write((cammy_tile *)dest->buf, x, y, dest->width, value);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -532,15 +525,15 @@ static void bitmap_copy(cammy_image *dest,
 | 
			
		|||
    int channels_dest = depth_channels(dest->depth),
 | 
			
		||||
        channels_src  = depth_channels(src->depth);
 | 
			
		||||
 | 
			
		||||
    for (y=0; y < from->height; y++) {
 | 
			
		||||
        if (to->y + y > dest->height) {
 | 
			
		||||
    for (y=from->y; y<from->y + from->height; y++) {
 | 
			
		||||
        if (y > dest->height) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (x=0; x < from->width; x++) {
 | 
			
		||||
        for (x=from->x; x<from->x + from->width; x++) {
 | 
			
		||||
            uint8_t r, g, b;
 | 
			
		||||
 | 
			
		||||
            if (to->x + x > from->width) {
 | 
			
		||||
            if (x > from->width) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -567,15 +560,15 @@ static void bitmap_copy_to_tile(cammy_image *dest,
 | 
			
		|||
 | 
			
		||||
    int channels = depth_channels(src->depth);
 | 
			
		||||
 | 
			
		||||
    for (y=0; y < from->height; y++) {
 | 
			
		||||
        if (to->y + y > dest->height) {
 | 
			
		||||
    for (y=from->y; y<from->y + from->height; y++) {
 | 
			
		||||
        if (y > dest->height) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (x=0; x < from->width; x++) {
 | 
			
		||||
        for (x=from->x; x<from->x + from->width; x++) {
 | 
			
		||||
            uint8_t r, g, b;
 | 
			
		||||
 | 
			
		||||
            if (to->x + x > from->width) {
 | 
			
		||||
            if (x > from->width) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -603,26 +596,23 @@ static void tile_copy_to_bitmap(cammy_image *dest,
 | 
			
		|||
 | 
			
		||||
    int channels = depth_channels(dest->depth);
 | 
			
		||||
 | 
			
		||||
    for (y=0; y < from->height; y++) {
 | 
			
		||||
        if (to->y + y > dest->height) {
 | 
			
		||||
    for (y=from->y; y<from->y + from->height; y++) {
 | 
			
		||||
        if (y > dest->height) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (x=0; x < from->width; x++) {
 | 
			
		||||
        for (x=from->x; x<from->x + from->width; x++) {
 | 
			
		||||
            uint8_t c;
 | 
			
		||||
 | 
			
		||||
            if (to->x + x > from->width) {
 | 
			
		||||
            if (x > from->width) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            c = tile_read((cammy_tile *)src->buf,
 | 
			
		||||
                          from->x + x,
 | 
			
		||||
                          from->y + y,
 | 
			
		||||
                          from->width);
 | 
			
		||||
            c = tile_read((cammy_tile *)src->buf, x, y, from->width);
 | 
			
		||||
 | 
			
		||||
            bitmap_write(dest->buf,
 | 
			
		||||
                         from->x + x,
 | 
			
		||||
                         from->y + y,
 | 
			
		||||
                         x,
 | 
			
		||||
                         y,
 | 
			
		||||
                         from->width,
 | 
			
		||||
                         src->palette[c].r,
 | 
			
		||||
                         src->palette[c].g,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue