Browse Source

experiment on incrustation

master
tth 10 months ago
parent
commit
6e410e5f50
6 changed files with 152 additions and 2 deletions
  1. +5
    -0
      .gitignore
  2. +16
    -1
      experiment/Makefile
  3. +3
    -1
      experiment/README.md
  4. +69
    -0
      experiment/assemblage.c
  5. +52
    -0
      experiment/incrustator.c
  6. +7
    -0
      experiment/incrustator.h

+ 5
- 0
.gitignore View File

@ -76,3 +76,8 @@ Fonderie/singlepass
Fonderie/crapdef.h
Fonderie/crapstr.h
experiment/assemblage
experiment/*.fimg
experiment/*.pnm
experiment/*.o

+ 16
- 1
experiment/Makefile View File

@ -1 +1,16 @@
# plasma experiment
#  experiments
COPT = -Wall -fpic -g -DDEBUG_LEVEL=0 -lm
DEPS = ../floatimg.h ../libfloatimg.a Makefile
LIBS = -ltiff -lpnglite -lcfitsio
all: assemblage
incrustator.o: incrustator.c incrustator.h Makefile
gcc -c $(COPT) $<
assemblage: assemblage.c Makefile incrustator.o
gcc $(COPT) $< incrustator.o ../libfloatimg.a $(LIBS) -o $@

+ 3
- 1
experiment/README.md View File

@ -1 +1,3 @@
# PLASMA EXPERIMENT
# ASSEMBLAGE

+ 69
- 0
experiment/assemblage.c View File

@ -0,0 +1,69 @@
/*
* assemblage experimental
*/
#include <stdio.h>
#include <stdlib.h>
#include "../floatimg.h"
#include "incrustator.h"
int verbosity;
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int premier_essai(int largeur, int hauteur, char *outname)
{
FloatImg grande, incrust;
int foo;
foo = fimg_create(&grande, largeur, hauteur, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "%s: Kkrkr %d pour create grande\n", __func__, foo);
return -1;
}
fimg_vdeg_a(&grande, 13.37);
foo = fimg_create(&incrust, 640, 480, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "%s: Kkrkr %d pour create incrust\n", __func__, foo);
return -1;
}
fimg_drand48(&incrust, 13.37);
foo = incrustator_0(&incrust, &grande, 100, 100, 0);
if (foo) {
fprintf(stderr, "%s: Kkrkr %d sur incrustator_0\n", __func__, foo);
return -1;
}
foo = fimg_export_picture(&grande, outname, 0);
if (foo) {
fprintf(stderr, "%s: error %d export '%s'\n", __func__,
foo, outname);
return -1;
}
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int main(int argc, char *argv[])
{
int foo;
verbosity = 1;
fimg_print_version(1);
foo = premier_essai(1280, 1024, "out.pnm");
if (foo) {
fprintf(stderr, "EPIC FAIL %s\n", argv[0]);
exit(1);
}
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */

+ 52
- 0
experiment/incrustator.c View File

@ -0,0 +1,52 @@
/*
* 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;
szl = psrc->width * sizeof(float);
for (y=0; y<psrc->height; y++) {
dstpos = ((y +ypos) * pdst->width) + xpos;
// 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->height;
}
return 0;
}
/* ---------------------------------------------------------------- */

+ 7
- 0
experiment/incrustator.h View File

@ -0,0 +1,7 @@
/*
* incrustator experimental
*/
int incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags);

Loading…
Cancel
Save