forked from tTh/FloatImg
buiding a test pattern generator
This commit is contained in:
parent
f451a8c8fe
commit
e1938dfaeb
|
@ -143,6 +143,7 @@ int fimg_load_from_png(char *filename, FloatImg *fimg);
|
|||
int fimg_create_from_png(char *filename, FloatImg *fimg);
|
||||
int fimg_save_as_png(FloatImg *src, char *outname, int flags);
|
||||
|
||||
int fimg_test_pattern(FloatImg *fimg, int type, double dval);
|
||||
int fimg_draw_something(FloatImg *fimg);
|
||||
|
||||
int parse_WxH(char *str, int *pw, int *ph);
|
||||
|
|
|
@ -11,6 +11,57 @@
|
|||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
int fimg_test_pattern(FloatImg *fimg, int type, double dval)
|
||||
{
|
||||
int nio;
|
||||
int x, y;
|
||||
float fr, fg, fb;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %d %g )\n", __func__, fimg, type, dval);
|
||||
#endif
|
||||
|
||||
if (fimg->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s need an rgb pic\n", __func__);
|
||||
return -6;
|
||||
}
|
||||
|
||||
/* rampe de primaires dans le quart du haut */
|
||||
|
||||
for (x=0; x<fimg->width; x++) {
|
||||
|
||||
nio = x / (fimg->width / 8);
|
||||
|
||||
switch(nio) {
|
||||
case 0:
|
||||
fr = 0.0, fg = 0.0, fb = 0.0; break;
|
||||
case 1:
|
||||
fr = 1.0, fg = 0.0, fb = 0.0; break;
|
||||
case 2:
|
||||
fr = 0.0, fg = 1.0, fb = 0.0; break;
|
||||
case 3:
|
||||
fr = 1.0, fg = 1.0, fb = 0.0; break;
|
||||
case 4:
|
||||
fr = 0.0, fg = 0.0, fb = 1.0; break;
|
||||
case 5:
|
||||
fr = 1.0, fg = 0.0, fb = 1.0; break;
|
||||
case 6:
|
||||
fr = 0.0, fg = 1.0, fb = 1.0; break;
|
||||
case 7:
|
||||
fr = 1.0, fg = 1.0, fb = 1.0; break;
|
||||
default:
|
||||
// abort();
|
||||
break;
|
||||
}
|
||||
|
||||
for (y=0; y<fimg->height/4; y++)
|
||||
fimg_plot_rgb(fimg, x, y, fr, fg, fb);
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_draw_something(FloatImg *fimg)
|
||||
{
|
||||
int x, y;
|
||||
|
|
Loading…
Reference in New Issue