not ready for prime time

This commit is contained in:
tth
2021-04-28 00:21:45 +02:00
parent 821377f666
commit bcc534a54d
12 changed files with 50 additions and 36 deletions

View File

@@ -8,10 +8,7 @@ LIBS = -ltiff -lpnglite -lcfitsio
all: assemblage extracteur
incrustator.o: incrustator.c incrustator.h Makefile
gcc -c $(COPT) $<
assemblage: assemblage.c Makefile incrustator.o
assemblage: assemblage.c Makefile
gcc $(COPT) $< incrustator.o ../libfloatimg.a $(LIBS) -o $@
extracteur: extracteur.c Makefile

View File

@@ -14,7 +14,7 @@ int verbosity;
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int print_rectangle(Rectangle *rect)
int print_rectangle(FimgArea51 *rect)
{
printf("rect @ %p : %dx%d at %d,%d\n", rect, rect->w, rect->h,
@@ -24,7 +24,7 @@ return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int essai_extraction(FloatImg *in, FloatImg *out, Rectangle *rect)
int essai_extraction(FloatImg *in, FloatImg *out, FimgArea51 *rect)
{
int foo;
int xs, ys, xd, yd;
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
{
int foo, opt;
FloatImg src, dst;
Rectangle zone;
FimgArea51 zone;
char *infile = "foo.fimg";
char *outfile = "out.fimg";

View File

@@ -1,92 +0,0 @@
/*
* incrustator experimental
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../floatimg.h"
#include "incrustator.h"
extern int verbosity;
/* ---------------------------------------------------------------- */
static int check_boundaries(FloatImg *from, FloatImg *to, FimgArea51 *a51)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, from, to, a51);
fimg_printdims("from", from);
fimg_printdims("to ", to);
#endif
/* just a small molly-guard */
if ( (a51->w < 0) || (a51->h < 0) ) {
fprintf(stderr, "%s: fubar on %p\n", __func__, a51);
abort(); /* FY Bro ! */
}
return -1;
}
/* ---------------------------------------------------------------- */
static int move_pixels(FloatImg *from, FloatImg *to,
FimgArea51 *a51, int flags)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p 0x%04x )\n", __func__,
from, to, a51, flags);
#endif
return -1;
}
/* ---------------------------------------------------------------- */
int incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags)
{
int y, srcpos, dstpos, szl;
int foo;
FimgArea51 area;
#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 */
area.x = xpos; area.y = ypos;
area.w = psrc->width; area.h = psrc->height;
foo = check_boundaries(psrc, pdst, &area);
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;
}
/* ---------------------------------------------------------------- */

View File

@@ -2,11 +2,8 @@
* incrustator experimental
*/
typedef struct {
unsigned long magic;
int w, h;
int x, y;
} FimgArea51;
/*
* MOVED TO 'funcs/inscrutator.c'
*/
int incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags);