The library interface is unstable.
See also: how to compress a DjVu file
#include <minidjvu.h>I'll assume that your compiler can find the minidjvu headers and your linker can link against the library. If not, try to read INSTALL or README, or try to add the parent release directory into the header search path.
This examples also require
#include <assert.h> #include <stdio.h> #include <stdlib.h>
const char *input = "your_input_file_name_here.djvu"; mdjvu_error_t error; mdjvu_image_t image = mdjvu_load_djvu_page(input, &error); if (!image) { fprintf(stderr, "%s: %s\n", input, mdjvu_get_error_message(error)); exit(1); }
mdjvu_bitmap_t bitmap = mdjvu_render(image); assert(bitmap);
const char *output = "your_output_file_name_here.pbm"; mdjvu_error_t error; if (!mdjvu_save_pbm(bitmap, output, &error)) { fprintf(stderr, "%s: %s\n", output, mdjvu_get_error_message(error)); exit(1); }Doing it with BMPs is pretty similar:
const char *output = "your_output_file_name_here.bmp"; mdjvu_error_t error; if (!mdjvu_save_bmp(bitmap, output, &error)) { fprintf(stderr, "%s: %s\n", output, mdjvu_get_error_message(error)); exit(1); }With TIFF, you can just call mdjvu_save_tiff(), but it's a good idea to check first whether TIFF support is compiled into minidjvu by calling
int have_tiff = mdjvu_have_tiff_support();
For the sake of completeness, there's a second declaration of error in this examples. Obviously, you should remove it if you plan to compile this.
mdjvu_image_destroy(image); mdjvu_bitmap_destroy(bitmap);