Compare commits

..

No commits in common. "8990d1f9a9ce7bd2be93a63b56f42ee74e14d264" and "9f42b813e77d6ee086291f11eb2b50c5ec2db2be" have entirely different histories.

4 changed files with 11 additions and 91 deletions

View File

@ -3,7 +3,7 @@
cp libfloatimg.a /usr/local/lib
cp floatimg.h /usr/local/include
cp tools/mkfimg tools/fimg2pnm tools/fimgops \
cp tools/mkfimg tools/fimg2pnm \
tools/png2fimg tools/fimgstats \
/usr/local/bin

View File

@ -36,7 +36,7 @@ for (idx=0; idx<nbiter; idx++) {
d->B[idx] = a->B[idx] + b->B[idx];
}
return 0;
return -1;
}
/* ---------------------------------------------------------------- */
/*
@ -63,7 +63,7 @@ for (idx=0; idx<nbiter; idx++) {
d->B[idx] = fabs(a->B[idx] - b->B[idx]);
}
return 0;
return -1;
}
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */
@ -91,6 +91,6 @@ for (idx=0; idx<nbiter; idx++) {
d->B[idx] = a->B[idx] * b->B[idx];
}
return 0;
return -1;
}
/* ---------------------------------------------------------------- */

View File

@ -9,8 +9,7 @@ int verbosity;
/* --------------------------------------------------------------------- */
#define OP_ADD 1
#define OP_SUB 2
#define OP_MUL 4
#define OP_MUL 2
typedef struct {
int code;
char *op;
@ -18,7 +17,6 @@ typedef struct {
Opcode opcodes[] = {
{ OP_ADD, "add" },
{ OP_SUB, "sub" },
{ OP_MUL, "mul" },
{ 0, NULL }
};
@ -30,17 +28,13 @@ for (optr = opcodes; optr->code; optr++) {
printf("\t%-20s %d\n", optr->op, optr->code);
}
}
static int look_opcode(char *txt)
static int look_opcodes(char *txt)
{
Opcode *optr;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, txt);
#endif
for (optr = opcodes; optr->code; optr++) {
if (!strcmp(txt, optr->op)) {
// printf("found %s as %d\n", optr->op, optr->code);
printf("found %s as %d\n", optr->op, optr->code);
return optr->code;
}
}
@ -56,33 +50,12 @@ if (verbosity) fimg_print_version(1);
exit(0);
}
/* --------------------------------------------------------------------- */
int exec_operator(FloatImg *A, FloatImg *B, int action, FloatImg *D)
{
int foo;
switch (action) {
case OP_ADD:
foo = fimg_add(A, B, D); break;
case OP_SUB:
foo = fimg_sub(A, B, D); break;
case OP_MUL:
foo = fimg_add(A, B, D); break;
default:
foo = -99; break;
}
return foo;
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo, opt, action;
int foo, opt;
float fvalue;
char *operator;
FloatImg srcA, srcB, dest;
FloatImg fimg;
while ((opt = getopt(argc, argv, "hk:v")) != -1) {
switch(opt) {
@ -103,53 +76,6 @@ if (4 != argc-optind) {
exit(1);
}
operator = argv[optind+2];
action = look_opcode(operator);
if (action < 0) {
fprintf(stderr, "%s : opcode '%s' unknow\n", argv[0], operator);
exit(1);
}
/*
* load the two source files, and check comatibility
*/
if ((foo=fimg_create_from_dump(argv[optind], &srcA))) {
fprintf(stderr, "read error on '%s' is %d\n", argv[optind], foo);
exit(2);
}
if ((foo=fimg_create_from_dump(argv[optind+1], &srcB))) {
fprintf(stderr, "read error on '%s' is %d\n", argv[optind+1], foo);
exit(3);
}
if (verbosity) { /* please, debug me */
fimg_describe(&srcA, argv[optind]);
fimg_describe(&srcB, argv[optind+1]);
}
foo = fimg_images_compatible(&srcA, &srcB);
if (foo) {
fprintf(stderr, "images are not compatibles, %d\n", foo);
exit(4);
}
/*
* we can now create the resultant image, and going coredump...
*/
foo = fimg_create(&dest, srcA.width, srcA.height, srcA.type);
// fimg_describe(&dest, "destination");
foo = exec_operator(&srcA, &srcB, action, &dest);
if (foo) {
fprintf(stderr, "operator exec give us a %d\n", foo);
}
foo = fimg_dump_to_file(&dest, argv[optind+3], 0);
if (foo) {
fprintf(stderr, "dumping datas to file give us a %d\n", foo);
}
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -2,7 +2,6 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include "../floatimg.h"
@ -15,9 +14,7 @@ int verbosity;
static int get_type(char *name)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
#endif
#define TEST(str) ( ! strcmp(name, str) )
if TEST("black") return T_BLACK;
@ -41,15 +38,14 @@ int main(int argc, char *argv[])
int foo, opt;
int width, height;
char *fname;
float fvalue = 0.00001;
float fvalue;
int type = 0;
FloatImg fimg;
while ((opt = getopt(argc, argv, "hk:t:v")) != -1) {
while ((opt = getopt(argc, argv, "ht:v")) != -1) {
switch(opt) {
case 'h': help(0); break;
case 'k': fvalue = atof(optarg); break;
case 't': type = get_type(optarg); break;
case 'v': verbosity++; break;
}
@ -71,8 +67,6 @@ width = atoi(argv[optind+1]); height = atoi(argv[optind+2]);
if (verbosity) fprintf(stderr, "making '%s' %d x %d\n", fname, width, height);
srand48(getpid() ^ time(NULL));
foo = fimg_create(&fimg, width, height, 3);
if (foo) {
fprintf(stderr, "create floatimg -> %d\n", foo);