Ahhh… Palette Swaps.
I’m leaving some Java snippet below. It takes an image containing red pixels (e.g., Ermac’s sprite sheet) and adjusts the hues of these pixels to match the given one.
void colorear(BufferedImage image,int n_hue) {
int c,r,g,b;
int w = image.getWidth();
int h = image.getHeight();
float hue = n_hue / 360f;
float hsb[] = new float[3];
for(int j = 0; j < w; j++)
for(int i = 0; i < h; i++) {
c = image.getRGB(i,j);
b = c & 255;
g = (c » 8) & 255;
r = (c » 16) & 255;
if(r > 0 && g == 0 && b == 0) {
Color.RGBtoHSB(r,g,b,hsb);
image.setRGB(i,j,Color.HSBtoRGB(hue,hsb[1],hsb[2]));
}
}
}
![unmanuel:
Ahhh… Palette Swaps.
I’m leaving some Java snippet below. It takes an image containing red pixels (e.g., Ermac’s sprite sheet) and adjusts the hues of these pixels to match the given one.
void colorear(BufferedImage image,int n_hue) { int c,r,g,b; int w = image.getWidth(); int h = image.getHeight(); float hue = n_hue / 360f; float hsb[] = new float[3]; for(int j = 0; j < w; j++) for(int i = 0; i < h; i++) { c = image.getRGB(i,j); b = c & 255; g = (c » 8) & 255; r = (c » 16) & 255; if(r > 0 && g == 0 && b == 0) { Color.RGBtoHSB(r,g,b,hsb); image.setRGB(i,j,Color.HSBtoRGB(hue,hsb[1],hsb[2])); } }}](http://29.media.tumblr.com/tumblr_lhanhsZJIX1qb1wcuo1_500.png)
