AMSwift
Posts: 15
Joined: 2/27/2019 Status: offline
|
Page 3 is devoted to light-colored frames and black-lined symbols. The core of the C code that allowed easy recoloring of white to black follows. It uses the FreeImage library, but this can easily be replaced if you have another preference.
/* For each row in the original image */
for (ximage = 0; ximage < width; ximage++)
{
/* And, along that row, each pixel */
for (yimage = 0; yimage < height; yimage++)
{
/* Get the color here */
(void)FreeImage_GetPixelColor(image_in, ximage, yimage, &this_color);
// Ignore fully transparent pixels
if (this_color.rgbReserved == 0) continue;
// Ignore pixels that aren't fully white
if ((this_color.rgbRed != 255) || (this_color.rgbGreen != 255) || (this_color.rgbBlue != 255)) continue;
// Turn the pixel black; retain the current transparency
this_color.rgbRed = 0;
this_color.rgbGreen = 0;
this_color.rgbBlue = 0;
(void)FreeImage_SetPixelColor(image_in, ximage, yimage, &this_color);
continue;
// Save this pixel
(void)FreeImage_SetPixelColor(image_in, ximage, yimage, &this_color);
}
}
Attachment (1)
< Message edited by AMSwift -- 4/7/2019 4:16:49 AM >
|