31 lines
603 B
C
31 lines
603 B
C
#include <libimg.h>
|
|
#include "libimg-internal.h"
|
|
|
|
void img_dye(img_t src, img_t dst, img_pixel_t color)
|
|
{
|
|
if(!img_target(dst, src.width, src.height)) return;
|
|
|
|
img_pixel_t *src_px = src.pixels;
|
|
img_pixel_t *dst_px = dst.pixels;
|
|
|
|
for(int y = 0; y < src.height; y++)
|
|
{
|
|
for(int x = 0; x < src.width; x++)
|
|
{
|
|
if(src_px[x] == IMG_ALPHA) continue;
|
|
dst_px[x] = color;
|
|
}
|
|
|
|
src_px += src.stride;
|
|
dst_px += dst.stride;
|
|
}
|
|
}
|
|
|
|
img_t img_dye_create(img_t src, img_pixel_t color)
|
|
{
|
|
img_t dst = img_create(src.width, src.height);
|
|
img_fill(dst, IMG_ALPHA);
|
|
img_dye(src, dst, color);
|
|
return dst;
|
|
}
|