RosettaCodeData/Task/Grayscale-image/C/grayscale-image-4.c

23 lines
426 B
C
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
image tocolor(grayimage img)
{
unsigned int x, y;
image timg;
luminance l;
unsigned int ofs;
timg = alloc_img(img->width, img->height);
for(x=0; x < img->width; x++)
{
for(y=0; y < img->height; y++)
{
ofs = (y * img->width) + x;
l = img->buf[ofs][0];
timg->buf[ofs][0] = l;
timg->buf[ofs][1] = l;
timg->buf[ofs][2] = l;
}
}
return timg;
}