#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <tthimage.h>
#include "floatimg.h"
/* -------------------------------------------------------- */
int add_tga_to_fimg(Image_Desc *src, FloatImg *dst)
{
int x, y;
float v;
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) {
v = ((float)Image_R_pixel(src, x, y) +
(float)Image_G_pixel(src, x, y) +
(float)Image_B_pixel(src, x, y)) / 20;
add_to_fimg_Rpix(dst, x, y, v);
}
}
return 0;
}
/* -------------------------------------------------------- */
int main(int argc, char *argv[])
{
FloatImg fimg;
int foo, tw, th;
Image_Desc *tga;
tga = Image_TGA_alloc_load(argv[1]);
if (NULL==tga) {
exit(1);
}
foo = get_floatimg_dims(argv[2], &tw, &th);
if (foo) { /* can't read the fimg dump */
create_floatimg(&fimg, tga->width, tga->height, 0);
clear_floatimg(&fimg);
}
else {
foo = create_floatimg_from_dump(argv[2], &fimg);
}
foo = add_tga_to_fimg(tga, &fimg);
foo = dump_floatimg(argv[2], &fimg);
return 0;
}
Quelques mois plus tard, la même fenêtre, avec un éclairage intérieur, une autre caméra et un dithering de monsieur Atkinson par dessus.