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 < h; j++)
for(int i = 0; i < w; 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]));
}
}
}
-
whatashithead reblogged this from unmanuel
-
absolutd reblogged this from unmanuel
-
sixcrazydevils liked this
-
baseblade liked this
-
davidhimaemissletoe reblogged this from unmanuel
-
libraryofthedeep liked this
-
datkidspade liked this
-
pseudoinverosimil liked this
-
nickitively liked this
-
ah-sei-la reblogged this from unmanuel
-
rattybluewizard liked this
-
expisition liked this
-
pleasequestionmysanity liked this
-
stockholmsyndrome47 reblogged this from unmanuel
-
likasbanana reblogged this from theorange
-
srtacherry reblogged this from marrimichelotti and added:
scorpion and kitana \o/
-
theorange reblogged this from unmanuel
-
marrimichelotti reblogged this from unmanuel
-
urmysoulsoul liked this
-
franqiitoh reblogged this from unmanuel
-
monroejigsaw liked this
-
markjustkeepsober liked this
-
shinlovee reblogged this from unmanuel
-
octopusorgasms liked this
-
jetjetplane liked this
-
theking84 reblogged this from unmanuel
-
b0sst0pher reblogged this from unmanuel
-
mbuchw reblogged this from unmanuel
-
mbuchw liked this
-
gihad liked this
-
ialienhead reblogged this from unmanuel
-
bigkev2real reblogged this from unmanuel and added:
my favorite Childhood memories!!!!!
-
ryanpatrickokeefe liked this
-
anyblair liked this
-
webofinfluence liked this
-
thefjproject reblogged this from the-nomad
-
gamemakers reblogged this from unmanuel
-
chiguire liked this
-
the-nomad reblogged this from unmanuel
-
2ne1inneverland liked this
-
starrrj liked this
-
advocat liked this
-
advocat reblogged this from unmanuel
-
samhallowell90 reblogged this from unmanuel
-
xxcolorblindxx reblogged this from unmanuel
-
xxcolorblindxx liked this
-
This was featured in #Gaming
-
unmanuel posted this
![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 < h; j++) for(int i = 0; i < w; 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])); } }}
To Part II ->](http://29.media.tumblr.com/tumblr_lhanhsZJIX1qb1wcuo1_500.png)
