Code:
function compare() {

	int p;	
	bmap_lock (bmp1,0);
	bmap_lock (bmp2,0);
	char* b1 = bmp1.finalbits;
	char* b2 = bmp2.finalbits;

	for (p=0;p<bmp1.finalwidth * bmp1.finalheight;p++)
		if (	b1[p*4  ] == find_color.blue &&
			b1[p*4+1] == find_color.green &&
			b1[p*4+2] == find_color.red) {

			b2[p*4  ] = new_color.blue;
			b2[p*4+1] = new_color.green;
			b2[p*4+2] = new_color.red;
			b2[p*4+3] = 255;}

	bmap_unlock(bmp1);
	bmap_unlock(bmp2);}


both bitmaps must have the same dimensions! If not, the result is either messed up or the engine crashes!