Bibliothèque de traitements d'images en virgule flottante. http://la.buvette.org/photos/cumul/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
1.8 KiB

1 year ago
/*
1 year ago
* halfsizing an fimg picture.
1 year ago
*/
#include <stdio.h>
#include <unistd.h> /* pour getopt */
#include <stdint.h>
1 year ago
#include <stdlib.h>
1 year ago
#include <string.h>
1 year ago
#include "../floatimg.h"
int verbosity;
/* ------------------------------------------------------------- */
1 year ago
int faire_un_halfsize(char *iname, char *oname, int to_gray)
1 year ago
{
FloatImg src, dst;
int foo;
foo = fimg_create_from_dump(iname, &src);
if (foo) {
fprintf(stderr, "create fimg from '%s' -> %d\n", iname, foo);
return -1;
}
memset(&dst, 0, sizeof(FloatImg));
foo = fimg_halfsize_1(&src, &dst, 0);
1 year ago
if (foo) {
fprintf(stderr, "halfize 1 fail -> %d\n", foo);
1 year ago
return -1;
}
1 year ago
if (to_gray) {
foo = fimg_to_gray(&dst);
/* and ? */
1 year ago
}
1 year ago
foo = fimg_dump_to_file(&dst, oname, 0);
if (foo) {
fprintf(stderr, "save to '%s' -> %d\n", oname, foo);
return -1;
}
1 year ago
return 0;
1 year ago
}
/* ------------------------------------------------------------- */
void help(int u)
{
puts("Usage:\n\tfimghalfsize [options] in.fimg out.fimg");
puts("Options:");
puts("\t-g\tconvert output to gray");
exit(0);
1 year ago
}
/* ------------------------------------------------------------- */
int main(int argc, char *argv[])
{
1 year ago
int foo, opt;
1 year ago
char *srcname = "";
char *dstname = "out.fimg";
1 year ago
int grayed = 0;
1 year ago
1 year ago
while ((opt = getopt(argc, argv, "ghv")) != -1) {
1 year ago
switch(opt) {
1 year ago
case 'g': grayed = 1; break;
1 year ago
case 'h': help(0); break;
case 'v': verbosity++; break;
}
}
if (2 != argc-optind) {
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
exit(1);
}
srcname = argv[optind];
dstname = argv[optind+1];
1 year ago
if (verbosity) {
fprintf(stderr, "%s: src: %s dst: %s\n", argv[0],
1 year ago
srcname, dstname);
1 year ago
}
1 year ago
1 year ago
foo = faire_un_halfsize(srcname, dstname, grayed);
if (foo) {
fprintf(stderr, "in %s: make halfsize give a %d\n", argv[0], foo);
exit(1);
}
1 year ago
return 0;
}
/* ------------------------------------------------------------- */