# from 0.48...
use Inline C => <<'EOS' => WITH => 'Imager';
void
inline_replace_color(Imager::ImgRaw img, Imager::Color from,
Imager::Color to) {
int x, y, ch;
i_color c;
for (x = 0; x < img->xsize; ++x) {
for (y = 0; y < img->ysize; ++y) {
int match = 1;
i_gpix(img, x, y, &c);
for (ch = 0; ch < img->channels; ++ch) {
if (c.channel[ch] != from->channel[ch]) {
match = 0;
break;
}
}
if (match)
i_ppix(img, x, y, to);
}
}
}
EOS
|