forked from tTh/FloatImg
added a new function : fimg_put_rgb
This commit is contained in:
parent
e9a61bb96a
commit
e128add5a6
2
Makefile
2
Makefile
@ -18,7 +18,7 @@ essai: essai.c libfloatimg.a floatimg.h Makefile
|
||||
TOTAR = *.[ch] Makefile *.sh *.md \
|
||||
doc/the*.tex doc/mk*.sh doc/*.txt \
|
||||
funcs/*.[ch] funcs/Makefile \
|
||||
tools/*.[ch] tools/READEME.md tools/Makefile \
|
||||
tools/*.[ch] tools/README.md tools/Makefile \
|
||||
v4l2/*.[ch] v4l2/Makefile \
|
||||
scripts/*.sh scripts/README.md \
|
||||
lib/*.[ch] lib/Makefile
|
||||
|
@ -62,6 +62,7 @@ int fimg_describe(FloatImg *head, char *txt);
|
||||
char *fimg_str_type(int type);
|
||||
int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b);
|
||||
int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
|
||||
int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb);
|
||||
int fimg_clear(FloatImg *fimg);
|
||||
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
|
||||
int fimg_rgb_constant(FloatImg *head, float r, float g, float b);
|
||||
|
@ -31,7 +31,9 @@ if (src->type != FIMG_TYPE_RGB) {
|
||||
|
||||
/* check if dst pic is not allocated */
|
||||
if ( 0 == (dst->type | dst->width | dst->height) ) {
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "in %s, %p is empty\n", __func__, dst);
|
||||
#endif
|
||||
/* OK allocate a new fpic */
|
||||
foo = fimg_create(dst, src->height, src->width, src->type);
|
||||
if (foo) {
|
||||
@ -54,7 +56,7 @@ if ( (src->type != dst->type) ||
|
||||
for (y=0; y<src->height; y++) {
|
||||
for (x=0; x<src->width; x++) {
|
||||
fimg_get_rgb(src, x, y, rgb);
|
||||
fimg_plot_rgb(dst, y, x, rgb[0], rgb[1], rgb[2]);
|
||||
fimg_put_rgb(dst, y, x, rgb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,3 +314,24 @@ prgb[2] = head->B[offset];
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* nouveau 24 mars 2020 - coronacoding */
|
||||
int fimg_put_rgb(FloatImg *head, int x, int y, float *prgb)
|
||||
{
|
||||
int offset;
|
||||
|
||||
if (head->type != FIMG_TYPE_RGB) {
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "%s : type %d is bad.\n", __func__, head->type);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset = x + (y * head->width);
|
||||
head->R[offset] = prgb[0];
|
||||
head->G[offset] = prgb[1];
|
||||
head->B[offset] = prgb[2];
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user