Bibliothèque de traitements d'images en virgule flottante.
http://la.buvette.org/photos/cumul/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
/* |
|
* incrustator experimental |
|
*/ |
|
|
|
#include <stdio.h> |
|
#include <string.h> |
|
|
|
#include "../floatimg.h" |
|
|
|
#include "incrustator.h" |
|
|
|
extern int verbosity; |
|
|
|
/* ---------------------------------------------------------------- */ |
|
int incrustator_0(FloatImg *psrc, FloatImg *pdst, |
|
int xpos, int ypos, int flags) |
|
{ |
|
int y, srcpos, dstpos, szl; |
|
|
|
#if DEBUG_LEVEL |
|
fprintf(stderr, ">>> %s ( %p %p %d %d 0x%04X\n", __func__, psrc, pdst, |
|
xpos, ypos, flags); |
|
#endif |
|
|
|
if (verbosity > 1) { |
|
fimg_describe(psrc, "source"); |
|
fimg_describe(pdst, "destination"); |
|
} |
|
|
|
/* check boudaries */ |
|
if ( (xpos < 0) || (xpos > pdst->width - psrc->width) || |
|
(ypos < 0) || (ypos > pdst->height - psrc->height) ) { |
|
fprintf(stderr, "%s: boudary error\n", __func__); |
|
return -2; |
|
} |
|
|
|
/* move all the data by looping over lines */ |
|
srcpos = 0; |
|
dstpos = (ypos * pdst->width) + xpos; |
|
szl = psrc->width * sizeof(float); |
|
for (y=0; y<psrc->height; y++) { |
|
// fprintf(stderr, " %7d %7d %7d\n", y, srcpos, dstpos); |
|
|
|
memcpy(pdst->R + dstpos, psrc->R + srcpos, szl); |
|
memcpy(pdst->G + dstpos, psrc->G + srcpos, szl); |
|
memcpy(pdst->B + dstpos, psrc->B + srcpos, szl); |
|
|
|
srcpos += psrc->width; |
|
dstpos += pdst->width; |
|
} |
|
|
|
return 0; |
|
} |
|
/* ---------------------------------------------------------------- */
|
|
|