Compare commits
No commits in common. "c7d7c8b2ddb9a7d9d767835e95e689982f03f2a0" and "998aee43fb8118cf44b58494ad27aedeb202cac1" have entirely different histories.
c7d7c8b2dd
...
998aee43fb
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
|
||||
lib/*.o
|
||||
lib/t
|
||||
funcs/*.o
|
||||
|
||||
*.a
|
||||
|
@ -43,7 +43,6 @@ int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
|
||||
|
||||
/* PNM files module */
|
||||
int fimg_save_as_pnm(FloatImg *head, char *fname, int notused);
|
||||
int fimg_load_from_pnm(char *fname, FloatImg *head, int notused);
|
||||
|
||||
double fimg_timer_set(int whot);
|
||||
double fimg_timer_get(int whot);
|
||||
|
@ -12,9 +12,6 @@ AR=ar
|
||||
|
||||
all: $(OBJS) ../libfloatimg.a
|
||||
|
||||
t: t.c ../libfloatimg.a $(DEPS)
|
||||
gcc $(COPT) $< ../libfloatimg.a -o $@
|
||||
|
||||
# --------------------------------------------
|
||||
|
||||
../libfloatimg.a: $(OBJS)
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "string.h"
|
||||
|
||||
#include "../floatimg.h"
|
||||
@ -15,67 +14,6 @@
|
||||
extern int verbosity; /* must be declared around main() */
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* nouveau juin 2019, pendant la Ravebish */
|
||||
|
||||
int fimg_load_from_pnm(char *fname, FloatImg *head, int notused)
|
||||
{
|
||||
FILE *fp;
|
||||
int width, height, maxval;
|
||||
int foo, line, column;
|
||||
unsigned char *buffline, *idxrd;
|
||||
float *Rptr, *Gptr, *Bptr;
|
||||
|
||||
if (NULL==head) {
|
||||
fprintf(stderr, "%s : head ptr is %p\n", __func__, head);
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (NULL==(fp=fopen(fname, "r"))) {
|
||||
perror(fname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foo = fscanf(fp, "P6 %d %d %d", &width, &height, &maxval);
|
||||
if (3 != foo) {
|
||||
fprintf(stderr, "%s : fscanf -> %d\n", __func__, foo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "%s is %dx%d , max=%d\n",fname, width, height, maxval);
|
||||
}
|
||||
|
||||
if (NULL==(buffline=calloc(3, width))) {
|
||||
fprintf(stderr, "%s on %s : memory error\n", __func__, fname);
|
||||
return -2;
|
||||
}
|
||||
|
||||
foo = fimg_create(head, width, height, 3);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s : create floatimg -> %d\n", __func__, foo);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fseek(fp, 1L, SEEK_CUR); /* black magic */
|
||||
|
||||
Rptr = head->R; Gptr = head->G; Bptr = head->B;
|
||||
for (line=0; line<height; line++) {
|
||||
foo = fread(buffline, 3, width, fp);
|
||||
fprintf(stderr, "line %d read %d\n", line, width);
|
||||
idxrd = buffline;
|
||||
for (column=0; column<width; column++)
|
||||
{
|
||||
*Rptr++ = (float)*idxrd++;
|
||||
*Gptr++ = (float)*idxrd++;
|
||||
*Bptr++ = (float)*idxrd++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
int fimg_save_as_pnm(FloatImg *head, char *fname, int notused)
|
||||
|
27
lib/t.c
27
lib/t.c
@ -1,27 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "string.h"
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo;
|
||||
FloatImg fimg;
|
||||
|
||||
verbosity = 1;
|
||||
|
||||
foo = fimg_load_from_pnm("/tmp/00000.ppm", &fimg, 0);
|
||||
|
||||
printf("retour du truc %d\n", foo);
|
||||
|
||||
fimg_printhead(&fimg);
|
||||
|
||||
fimg_save_as_pnm(&fimg, "foo.pnm", 0);
|
||||
|
||||
return 0;
|
||||
}
|
@ -8,8 +8,7 @@ DEPS = ../floatimg.h ../libfloatimg.a Makefile
|
||||
|
||||
# ----------
|
||||
|
||||
all: fimg2pnm addtga2fimg mkfimg png2fimg fimgstats fimg2png \
|
||||
addpnm2fimg
|
||||
all: fimg2pnm addtga2fimg mkfimg png2fimg fimgstats fimg2png
|
||||
|
||||
fimgstats: fimgstats.c $(DEPS)
|
||||
gcc -g $< ../libfloatimg.a -o $@
|
||||
@ -26,10 +25,6 @@ fimg2png: fimg2png.c $(DEPS)
|
||||
addtga2fimg: addtga2fimg.c $(DEPS)
|
||||
gcc -g $< ../libfloatimg.a -limageSO -lm -o $@
|
||||
|
||||
addpnm2fimg: addpnm2fimg.c $(DEPS)
|
||||
gcc -g $< ../libfloatimg.a -limageSO -lm -o $@
|
||||
|
||||
|
||||
# if "undefined reference to crc32" then "use -lz"
|
||||
png2fimg: png2fimg.c $(DEPS)
|
||||
gcc -g $< ../libfloatimg.a -lpnglite -o $@
|
||||
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* ADDPNM
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int add_pnm_to_fimg(char *srcname, char *dstname, int notused)
|
||||
{
|
||||
FloatImg dst, src;
|
||||
int foo, x, y, idx;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %s' )\n", __func__, srcname, dstname);
|
||||
#endif
|
||||
|
||||
foo = fimg_create_from_dump(dstname, &dst);
|
||||
if (foo) fprintf(stderr, "create dst fimg from '%s' -> %d\n", dstname, foo);
|
||||
#if DEBUG_LEVEL
|
||||
fimg_describe(&dst, "created fimg from dump");
|
||||
#endif
|
||||
|
||||
foo = fimg_load_from_pnm(srcname, &src, 0);
|
||||
if (foo) fprintf(stderr, "create src fimg from '%s' -> %d\n", dstname, foo);
|
||||
#if DEBUG_LEVEL
|
||||
fimg_describe(&qrc, "created fimg from PNM");
|
||||
#endif
|
||||
|
||||
idx = 0;
|
||||
for (y=0; y<src.height; y++) {
|
||||
for (x=0; x<src.width; x++) {
|
||||
dst.R[idx] += src.R[idx];
|
||||
dst.G[idx] += src.G[idx];
|
||||
dst.B[idx] += src.B[idx];
|
||||
}
|
||||
}
|
||||
|
||||
foo = fimg_dump_to_file(&dst, dstname, 0);
|
||||
if (foo) { fprintf(stderr, "fimg dump -> %d\n", foo); }
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo;
|
||||
// int srcW, srcH;
|
||||
int infos[3];
|
||||
|
||||
if (3 != argc) {
|
||||
fimg_print_version(1);
|
||||
fprintf(stderr, "usage:\n\t%s img.fimg cumul.fimg\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( 0==access(argv[2], R_OK|W_OK) ) { /* fimg is readable */
|
||||
fprintf(stderr, "%s exist\n", argv[2]);
|
||||
}
|
||||
/*
|
||||
else {
|
||||
fprintf(stderr, "*** must create '%s' %dx%d first !!!\n",
|
||||
argv[2], tgaW, tgaH);
|
||||
exit(1);
|
||||
} */
|
||||
|
||||
foo = fimg_fileinfos(argv[2], infos);
|
||||
// fprintf(stderr, "get dims of '%s' -> %d\n", argv[2], foo);
|
||||
if (foo) {
|
||||
fprintf(stderr, "*** %s is badly broken\n", argv[2]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/*
|
||||
if ( (tgaW != infos[0]) || (tgaW != infos[0]) ) {
|
||||
fprintf(stderr, " TGA %5d %5d\n", tgaW, tgaH);
|
||||
fprintf(stderr, " FIMG %5d %5d\n", infos[0], infos[1]);
|
||||
fprintf(stderr, " No dimension match.\n");
|
||||
exit(3);
|
||||
}
|
||||
*/
|
||||
|
||||
foo = add_pnm_to_fimg(argv[1], argv[2], 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
@ -9,8 +9,6 @@
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
int verbosity = 0;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -194,7 +194,6 @@ for (i = 0; i < nbre_capt; i++) {
|
||||
fmt.fmt.pix.width, fmt.fmt.pix.height);
|
||||
fwrite(buffers[buf.index].start, buf.bytesused, 1, fout);
|
||||
fclose(fout);
|
||||
|
||||
if (nbre_capt > 1 && period) {
|
||||
sleep(period);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user