For a game that I am currently making, I have a black background with many white dots, which are being used to represent stars. I have no need for the black color however, and I only wish for the stars to show. My question is this: Is it possible to completely hide the black color without using an image manipulation program, that is, using only code? Any help is appreciated.
Asked
Active
Viewed 121 times
0
-
How do you mean you don't want the black background? Should it be white or clear (no color)? Please elaborate a bit. (If it's white the stars will not be visible obviously) – Manuel Apr 23 '12 at 09:19
-
Please excuse my lack of description, what I meant to say was that I wish to remove the black and leave full transparency in its place. This would leave only the white stars. – Fitzy Apr 23 '12 at 09:27
1 Answers
0
This is the form:
// some rgba color representation
struct t_rgba {
uint8_t r, g, b, a;
};
bool SetToTransparentIfPixelIsBlack(t_rgba* const rgba) {
// is it black?
if (0 == rgba->r && 0 == rgba->g && 0 == rgba->b) {
// then set the alpha value to transparent:
rgba->a = 0;
}
}
although the image data you are using will be represented differently.

justin
- 104,054
- 14
- 179
- 226
-
thanks, but the declaration of that struct doesnt actually assign every pixel in the image to its correct value, does it? – Fitzy Apr 24 '12 at 06:48
-