simple_bmp.h
// transparency = 1 for full transparency
transparency = 1 for full transparency
transparency = 1 for full transparency
void BMP_BlendPixel(BMP *image, int x, int y, unsigned char *rgb, double transparency)
{
	if(x < image->w && y < image->h && x >= 0 && y >= 0)
	for(int c = 0; c < 3; c++)
	{
		unsigned char *current_rgb = &rgb[2-c];
		unsigned char *current_buffer = &image->buffer[(image->h-1-y)*(image->w*3 + image->padding_bytes)+x*3+c];
		double colA = (double)*current_buffer;
		double colB = (double)*current_rgb;
		double colResult = colA * transparency + colB * (1 - transparency);
		*current_buffer = (unsigned char)colResult;
	}
}
void BMP_BlendPixel ( BMP * image , int x , int y , unsigned char * rgb , double transparency ) { if ( x < image -> w && y < image -> h && x >= 0 && y >= 0 ) for ( int c = 0 ; c < 3 ; c ++ ) { unsigned char * current_rgb = & rgb [ 2 - c ] ; unsigned char * current_buffer = & image -> buffer [ ( image -> h - 1 - y ) * ( image -> w * 3 + image -> padding_bytes ) + x * 3 + c ] ; double colA = ( double ) * current_buffer ; double colB = ( double ) * current_rgb ; double colResult = colA * transparency + colB * ( 1 - transparency ) ; * current_buffer = ( unsigned char ) colResult ; } }
transparency = 1 for full transparency
transparency = 1 for full transparency