you must write a conversion function, which has as input the old color and returns the new color. Run this function on every pixel of the image.
pseudo code:
Picture pic1;
Picture pic2;
for( int x=0; x<ypic1.width();x++)> for( int y=0; xy<pic1.heigth();y++)> Color clr1 = pic1.getColor(x,y);
Color clr2 = myConversion(clr1);
pic2.setPixel(x,y,clr2);
}
}