0
votes

I'm using the red/green/blue channels of an image to create a custom mask for a game. The red & green channels are going to be gradient images, and the blue channel is going to have single-pixel markers on it:

enter image description here

The blue pixels in that image are blown up to more than one pixel so that they're visible, and hopefully that conveys my meaning. The red channel is used to mask a character, the green channel is used to mask some items, the blue channel (the little dots you see) is used to signify markers. Each blue pixel will actually be slightly different (255, 254, 253, 252, etc). The problem is that since the red and green channels are full gradients, any data on the blue channel, when saved off as an 8bit png, gets completely drowned out and those pixels just vanish (since the color table assigns all 256 colors to red and green colors). So I'm trying to figure out if it's possible to put a hard preservation on the blue channel, basically saying "Keep the blue value exact, no matter what". This isn't important on the other channels since they're going to get converted to alpha masks anyway, so a couple pixels off in one direction or the other doesn't matter.

And ideas? It'd be nice if there's some way to get IM to do this for me, but my fallback is to hopefully figure out how to manually define the entire 256-color palette that's used when saving off an 8-bit png. I'd basically read in the pixels for the whole image and write my own table, making sure to preserve the blue channel no matter what.

1
Is there any reason why you can't just use a 24-bit PNG?Roger Rowland
bandwidth. This is one frame of a character that has 20-40 frames of animation. This leads to ~300kb 24-bit pngs vs ~100kb 8-bit pngs. Multiply by approx 100 images and it's 10MB vs 30MB if every spritesheet needs to be downloaded.Mark Kahn

1 Answers

1
votes

Sometimes the best answer isn't the one you were expecting.

per the same question posted on reddit, it makes more sense to write a tool to save off the locations of my blue pixels then simply re-encode the image (sans-blue) as an 8-bit png.