mzapo_canvas.c
void Canvas2CanvasChopped(	Canvas* A, // Original canvas
						unsigned int A_start_x, // x,y coord of starting chopping pixel
						unsigned int A_start_y, 
						unsigned int A_x_w, // width and height of chopped part 
						unsigned int A_y_h, 
						Canvas* B, // Target canvas
						unsigned int B_x, // Target coord in B canvas
						unsigned int B_y,
						bool transparent, 
						RGB* transparent_color){
						
	// Iterate image a and copy pixel by pixel values from canvas A to B
	for(int A_y = A_start_y; A_y < (A_y_h+A_start_y); A_y++){
		for(int A_x = A_start_x; A_x < (A_x_w+A_start_x); A_x++){
			// Check boundraries
			unsigned int Target_x = A_x + B_x; // Origin from A + offset
			unsigned int Target_y = A_y + B_y; // Origin from A + offset
			
			if((Target_x < B->w) && (Target_y < B->h) && (A_x < A->w) && (A_y < A->h) 
					 && (Target_x > 0) && (Target_y > 0) && (A_x > 0) && (A_y > 0)){ 
				// Grab pixel from canvas A and copy it to canvas B
				RGB color = GetPixelValue(A_x, A_y, A); // From A
				
				// Should this color be ignored ?
				
				if((color.R == transparent_color->R) && (color.G == transparent_color->G) && (color.B == transparent_color->B) && (transparent == true)){
					continue; // Transparent pixel
				}else{
					ColorCanvasPixel(Target_x, Target_y, &color, B); // Color B
				}
				
				
			}else{
				continue; // Out of bounds
			}
		}
	}
	return;
}
/*  This functions takes one canvas A and copies is to another cavnas B.
	A_start_x, A_start_y are the coordinates we will be choping from copied canvas and 
	B_x, B_y are the coordinates where we will place our A canvas.
	Size of the copped piece is specified in A_x_w
	No need to worry about overflow. It's taken care of.  */
This functions takes one canvas A and copies is to another cavnas B.
A_start_x, A_start_y are the coordinates we will be choping from copied canvas and
B_x, B_y are the coordinates where we will place our A canvas.
Size of the copped piece is specified in A_x_w
No need to worry about overflow. It's taken care of.
This functions takes one canvas A and copies is to another cavnas B . A_start_x A_start_y are the coordinates we will be choping from copied canvas and B_x B_y are the coordinates where we will place our A canvas . Size of the copped piece is specified in A_x_w No need to worry about overflow . It ' s taken care of .
void Canvas2CanvasChopped(	Canvas* A, 
						unsigned int A_start_x, 
						unsigned int A_start_y, 
						unsigned int A_x_w, 
						unsigned int A_y_h, 
						Canvas* B, 
						unsigned int B_x, 
						unsigned int B_y,
						bool transparent, 
						RGB* transparent_color){
	for(int A_y = A_start_y; A_y < (A_y_h+A_start_y); A_y++){
		for(int A_x = A_start_x; A_x < (A_x_w+A_start_x); A_x++){
			unsigned int Target_x = A_x + B_x; 
			unsigned int Target_y = A_y + B_y; 
			if((Target_x < B->w) && (Target_y < B->h) && (A_x < A->w) && (A_y < A->h) 
					 && (Target_x > 0) && (Target_y > 0) && (A_x > 0) && (A_y > 0)){ 
				RGB color = GetPixelValue(A_x, A_y, A); 
				if((color.R == transparent_color->R) && (color.G == transparent_color->G) && (color.B == transparent_color->B) && (transparent == true)){
					continue; 
				}else{
					ColorCanvasPixel(Target_x, Target_y, &color, B); 
				}
			}else{
				continue; 
			}
		}
	}
	return;
}
void Canvas2CanvasChopped ( Canvas * A , unsigned int A_start_x , unsigned int A_start_y , unsigned int A_x_w , unsigned int A_y_h , Canvas * B , unsigned int B_x , unsigned int B_y , bool transparent , RGB * transparent_color ) { for ( int A_y = A_start_y ; A_y < ( A_y_h + A_start_y ) ; A_y ++ ) { for ( int A_x = A_start_x ; A_x < ( A_x_w + A_start_x ) ; A_x ++ ) { unsigned int Target_x = A_x + B_x ; unsigned int Target_y = A_y + B_y ; if ( ( Target_x < B -> w ) && ( Target_y < B -> h ) && ( A_x < A -> w ) && ( A_y < A -> h ) && ( Target_x > 0 ) && ( Target_y > 0 ) && ( A_x > 0 ) && ( A_y > 0 ) ) { RGB color = GetPixelValue ( A_x , A_y , A ) ; if ( ( color . R == transparent_color -> R ) && ( color . G == transparent_color -> G ) && ( color . B == transparent_color -> B ) && ( transparent == true ) ) { continue ; } else { ColorCanvasPixel ( Target_x , Target_y , & color , B ) ; } } else { continue ; } } } return ; }
This functions takes one canvas A and copies is to another cavnas B.
A_start_x, A_start_y are the coordinates we will be choping from copied canvas and
B_x, B_y are the coordinates where we will place our A canvas.
This functions takes one canvas A and copies is to another cavnas B . A_start_x A_start_y are the coordinates we will be choping from copied canvas and B_x B_y are the coordinates where we will place our A canvas .
// Original canvas // x,y coord of starting chopping pixel // width and height of chopped part  // Target canvas // Target coord in B canvas // Iterate image a and copy pixel by pixel values from canvas A to B // Check boundraries // Origin from A + offset // Origin from A + offset // Grab pixel from canvas A and copy it to canvas B // From A // Should this color be ignored ? // Transparent pixel // Color B // Out of bounds