not ready for prime time
This commit is contained in:
@@ -11,7 +11,7 @@ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
|
||||
geometry.o rotate.o fimg-openexr.o \
|
||||
equalize.o fimg-fits.o saturation.o histogram.o \
|
||||
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
|
||||
displacement.o dithering.o plasmas.o
|
||||
displacement.o dithering.o plasmas.o incrustator.o
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
||||
@@ -33,7 +33,12 @@ tests.o: tests.c tests.h $(DEPS)
|
||||
../libfloatimg.a: $(OBJS)
|
||||
$(AR) r $@ $?
|
||||
|
||||
displacement.o: displacement.c $(DEPS)
|
||||
# ###
|
||||
|
||||
incrustator.o: incrustator.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
displacement.o: displacement.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
fimg-png.o: fimg-png.c $(DEPS)
|
||||
|
||||
@@ -105,7 +105,7 @@ for (y=0; y<hd; y++) {
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_extractor(FloatImg *in, FloatImg *out, Rectangle *rect)
|
||||
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect)
|
||||
{
|
||||
int foo;
|
||||
int xs, ys, xd, yd;
|
||||
@@ -136,6 +136,8 @@ for (yd=0; yd<rect->h; yd++) {
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* ho, btw, you can have a locck at 'incrustator.c' :) */
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused)
|
||||
{
|
||||
float *fptr;
|
||||
|
||||
93
funcs/incrustator.c
Normal file
93
funcs/incrustator.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* incrustator experimental
|
||||
* KRKRK
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
// XXX #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 fimg_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;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FloatImg library from tTh - ugly code inside
|
||||
* FloatImg library from tTh - really ugly code inside
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../floatimg.h"
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* global vars from main
|
||||
/* global vars exported from main
|
||||
*/
|
||||
extern int verbosity;
|
||||
|
||||
@@ -28,7 +28,6 @@ if (FIMG_TYPE_RGB != img->type) {
|
||||
|
||||
for (y=0; y<img->height; y++) {
|
||||
p = y * img->width; /* first pixel of the row */
|
||||
|
||||
for (x=0; x<img->width; x++) {
|
||||
|
||||
gr = (img->R[p] + img->G[p] + img->R[p]) / 3.0;
|
||||
@@ -36,15 +35,12 @@ for (y=0; y<img->height; y++) {
|
||||
img->R[p] = ((gr * mix) + (img->R[p] * (1.0-mix))) / 2.0;
|
||||
img->G[p] = ((gr * mix) + (img->G[p] * (1.0-mix))) / 2.0;
|
||||
img->B[p] = ((gr * mix) + (img->B[p] * (1.0-mix))) / 2.0;
|
||||
|
||||
p++; /* next pixel in the row */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/*
|
||||
* The third parameter was a six value array with min and max
|
||||
@@ -60,7 +56,6 @@ if (FIMG_TYPE_RGB != s->type) {
|
||||
}
|
||||
|
||||
sz = s->width * s->height;
|
||||
|
||||
for (idx=0; idx<sz; idx++) {
|
||||
d->R[idx] = s->R[idx] - coefs[0];
|
||||
d->G[idx] = s->G[idx] - coefs[2];
|
||||
@@ -69,10 +64,10 @@ for (idx=0; idx<sz; idx++) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/*
|
||||
* I think that this function is fully buggy
|
||||
* I think that this function is fully buggy, and need
|
||||
* more explanations.
|
||||
*/
|
||||
int fimg_auto_shift_to_zero(FloatImg *src, FloatImg *dst)
|
||||
{
|
||||
@@ -80,6 +75,10 @@ float coefs[6];
|
||||
int foo;
|
||||
float minima = 1e7; /* magic value ? */
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
|
||||
#endif
|
||||
|
||||
if (FIMG_TYPE_RGB != src->type) {
|
||||
fprintf(stderr, "%s: bad image type %d\n", __func__, src->type);
|
||||
return -6;
|
||||
|
||||
@@ -75,7 +75,7 @@ return -1;
|
||||
/*
|
||||
* /!\ return 4 on success
|
||||
*/
|
||||
int parse_rectangle(char *str, Rectangle *r, int notused)
|
||||
int parse_rectangle(char *str, FimgArea51 *r, int notused)
|
||||
{
|
||||
int x, y, w, h, foo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user