It seems as though you are trying to perform a palette swap?
If so, drawing the image from the 1st image onto the 2nd is not the correct approach.
When drawing onto an Image with an IndexColorModel it isn't just a case of copying the source raster onto the destination raster, the source colors must be mapped onto the closest color in the destination palette.
Obviously if the palettes of your 2 BufferedImages are dissimilar this process will not result in the outcome you want. (The mapping process can also be very slow)
What you should do is construct the 2nd BufferedImage using the Raster of your 1st BufferedImage (bi1.getRaster()), but providing a different (new) ColorModel.
The constructor you will be wanting is:
BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
I'm unsure if a copy of the provided raster is taken, you might find that the 2 images end up sharing the same Raster... which might or might not be desirable, depending upon what you intend to do with the images.
You can ofcourse clone the Raster if sharing is not desirable.