101 lines
1.9 KiB
C
101 lines
1.9 KiB
C
/*
|
|
testing some random funcs.
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include <string.h>
|
|
|
|
#include "floatimg.h"
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
int add(FloatImg *a, FloatImg *b)
|
|
{
|
|
int x, y;
|
|
int offset;
|
|
double tb;
|
|
|
|
fimg_timer_set(0);
|
|
|
|
for (x=0; x<a->width; x++) {
|
|
for (y=0; y<a->height; y++) {
|
|
offset = x + (y * a->width);
|
|
a->R[offset] += b->R[offset];
|
|
a->G[offset] += b->G[offset];
|
|
a->B[offset] += b->B[offset];
|
|
}
|
|
}
|
|
|
|
tb = fimg_timer_get(0);
|
|
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
|
|
|
return 0;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
void fait_un_dessin(char *fname)
|
|
{
|
|
FloatImg dessin;
|
|
double tb;
|
|
|
|
puts("");
|
|
fimg_timer_set(0);
|
|
fimg_create(&dessin, 3200, 2400, 3);
|
|
fimg_draw_something(&dessin);
|
|
fimg_dump_to_file(&dessin, "dessin.fimg", 0);
|
|
fimg_destroy(&dessin);
|
|
tb = fimg_timer_get(0);
|
|
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
|
|
|
puts("");
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
FloatImg fimgA, fimgB;
|
|
int foo;
|
|
double tb;
|
|
|
|
fimg_print_version(0);
|
|
|
|
#define W 2000
|
|
#define H 1700
|
|
|
|
fait_un_dessin("dessin.fimg");
|
|
|
|
fimg_create(&fimgA, W, H, 3);
|
|
fimg_create(&fimgB, W, H, 3);
|
|
|
|
fimg_draw_something(&fimgA);
|
|
|
|
fimg_timer_set(0);
|
|
fimg_drand48(&fimgB, 100.0);
|
|
tb = fimg_timer_get(0);
|
|
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
|
|
|
foo = fimg_save_as_pnm(&fimgB, "drand48.pnm", 0);
|
|
|
|
/*
|
|
fimg_printhead(&fimgA); fimg_printhead(&fimgB);
|
|
fimg_describe(&fimgA, "image A");
|
|
*/
|
|
|
|
add(&fimgA, &fimgB);
|
|
|
|
foo = fimg_save_as_pnm(&fimgA, "t.pnm", 0);
|
|
fprintf(stderr, "save as pnm -> %d\n", foo);
|
|
foo = fimg_dump_to_file(&fimgA, "t.fimg", 0);
|
|
fprintf(stderr, "save as fimg -> %d\n", foo);
|
|
|
|
fimg_destroy(&fimgA);
|
|
fimg_destroy(&fimgB);
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|