#include "lib/lib.h"
#include "lib/getopt.h"
#include "lib/fastbuf.h"
+#include "lib/mempool.h"
#include "images/images.h"
#include "images/color.h"
#include "images/duplicates.h"
{ "transormations", 0, 0, 't' },
{ NULL, 0, 0, 0 }
};
-
+
static uns verbose = 1;
static byte *file_name_1;
static byte *file_name_2;
static struct color background_color;
static uns transformations = IMAGE_DUP_TRANS_ALL;
-#define MSG(x...) do{ if (verbose) log(L_INFO, ##x); }while(0)
+#define MSG(x...) do{ if (verbose) msg(L_INFO, ##x); }while(0)
int
main(int argc, char **argv)
file_name_1 = argv[optind++];
file_name_2 = argv[optind];
-#define TRY(x) do{ if (!(x)) die("Error: %s", it.err_msg); }while(0)
+#define TRY(x) do{ if (!(x)) exit(1); }while(0)
MSG("Initializing image library");
- struct image_thread it;
+ struct image_context ctx;
struct image_io io;
- image_thread_init(&it);
+ image_context_init(&ctx);
struct image *img1, *img2;
- if (!image_io_init(&it, &io))
- die("Cannot initialize image I/O (%s)", it.err_msg);
+ TRY(image_io_init(&ctx, &io));
MSG("Reading %s", file_name_1);
io.fastbuf = bopen(file_name_1, O_RDONLY, 1 << 18);
io.format = format_1 ? : image_file_name_to_format(file_name_1);
struct image_dup dup1, dup2;
struct mempool *pool = mp_new(1 << 18);
MSG("Creating internal structures");
- TRY(image_dup_init(&it, &dup1, img1, pool));
- TRY(image_dup_init(&it, &dup2, img2, pool));
+ TRY(image_dup_init(&ctx, &dup1, img1, pool));
+ TRY(image_dup_init(&ctx, &dup2, img2, pool));
MSG("Similarity bitmap %02x", image_dup_compare(&dup1, &dup2, transformations | IMAGE_DUP_SCALE | IMAGE_DUP_WANT_ALL));
image_destroy(img1);
image_destroy(img2);
- image_thread_cleanup(&it);
+ image_context_cleanup(&ctx);
MSG("Done.");
return 0;
}