I am trying to create a mathlink module for Mathematica that can read files of the type DJVU. After a few days of trying I still have no success. This is what I've done so far:
Downloaded and compiled ImageMagick 6.5.4. (8 bit mode)
Downloaded and compiled DjvuLibre 3.5.22.
I added the define MAGICKCORE_DJVU_DELEGATE
Did some minor hacking (see below)
After compiling the code and linking it to my project, i tried reading the file using this code:
Code: Select all
void ImportDJVU()
{
// Download values from the link
const char * path;
MLGetString(stdlink, &path);
Magick::Image image;
try
{
// Read a file into image object
image.read( path );
}
catch( Magick::Exception &error_ )
{
std::cout << "Caught exception: " << error_.what() << "\n";
}
MLPutString(stdlink, path);
MLReleaseString(stdlink, path);
}
Code: Select all
Assertion failed: image_info->signature == MagickSignature, file ..\..\coders\djvu.c, line 765
Sincerely,
Gao Han
PS: Had to do some minor hacking otherwise I got into trouble with compiling (VS2008)
Code: Select all
/* // Originally:
q = (unsigned char *) malloc(lc->image->columns
#if RGB
* 3
#endif
);*/
// Changed into:
#if RGB
q = (unsigned char *) malloc(lc->image->columns * 3);
#else
q = (unsigned char *) malloc(lc->image->columns);
#endif