new func: fimg_do_stripes(&fimg, 0);

This commit is contained in:
tTh
2022-09-19 11:58:30 +02:00
parent eedc9197db
commit 56073c0c80
3 changed files with 56 additions and 10 deletions

View File

@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include "../floatimg.h"
@@ -23,8 +24,7 @@ if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__);
return -6;
}
for (x=0; x<img->width; x++)
{
for (x=0; x<img->width; x++) {
value = (float)x / (float)img->width;
value *= dcoef;
for (y=0; y<img->height; y++) {
@@ -51,11 +51,10 @@ if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__);
return -6;
}
for (y=0; y<img->height; y++)
{
value = (float)y / (float)img->height;
for (x=0; x<img->width; x++) {
value = (float)x / (float)img->width;
value *= dcoef;
for (x=0; x<img->width; x++) {
for (y=0; y<img->height; y++) {
fimg_plot_rgb(img, x, y, value, value, value);
}
}
@@ -63,3 +62,47 @@ for (y=0; y<img->height; y++)
return 0;
}
/* --------------------------------------------------------------------- */
/* nouveau 19 septembre 2022 */
int fimg_do_stripes(FloatImg *img, int mode)
{
int x, y, quad;
float *ligne;
float fr, fg, fb;
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, img, mode);
/*
* allocate and fill a lookup table
*/
if (NULL==(ligne=malloc(img->width*sizeof(float)))) {
fprintf(stderr, "%s: malloc fail\n", __func__);
exit(1);
}
for (x=0; x<img->width; x++)
ligne[x] = (float)x / (float)img->width;
/*
* build the pixels
*/
for (y=0; y<img->height; y++)
{
quad = (y*4) / img->height ;
for (x=0; x<img->width; x++) {
fr = fg = fb = ligne[x];
switch(quad) {
case 0: fg = fb = 0; break;
case 1: fr = fb = 0; break;
case 2: fr = fg = 0; break;
case 3: break;
default: abort(); break;
}
fimg_plot_rgb(img, x, y, fr, fg, fb);
}
}
free(ligne);
return 0;
}
/* --------------------------------------------------------------------- */