Package: libdjvulibre21
Version: 3.5.24-3
(I'm not entirely sure if change of the behaviour I noticed is actually a bug,
but it's definitely *weird*.)
The ddjvu_thumbnail_render function in libdjvulibre21 3.5.24-3 on i386
produces different results than it used to.
To show this problem, I wrote a short program that generates a small (at
most 5x5) thumbnail and prints its hex representation on stdout.
With libdjvulibre21 3.5.24-3 on i386 the output is as follows:
$ ./thumbtest /usr/share/doc/libdjvulibre-dev/djvu3spec.djvu
ee e7 f0
e9 e7 ef
e8 e5 ee
e9 e2 ee
ed ea f0
With every other version I tested (3.5.24-2/i386, 3.5.24-1/i386, 3.5.23-3/i386,
3.5.23-3/amd64 and even 3.5.24-3/amd64), it is:
$ ./thumbtest /usr/share/doc/libdjvulibre-dev/djvu3spec.djvu
f7 ed f8
f0 ec f8
ef ea f6
f0 e6 f5
f4 f1 f9
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'experimental')
Architecture: i386 (x86_64)
Kernel: Linux 2.6.38-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libdjvulibre21 depends on:
ii libc6 2.13-4 Embedded GNU C Library: Shared lib
ii libdjvulibre-text 3.5.24-3 Linguistic support files for libdj
ii libgcc1 1:4.6.0-7 GCC support library
ii libjpeg62 6b1-1 The Independent JPEG Group's JPEG
ii libstdc++6 4.6.0-7 The GNU Standard C++ Library v3
--
Jakub Wilk
#include <stdio.h>
#include <stdlib.h>
#include <libdjvu/ddjvuapi.h>
void handle_ddjvu_messages(ddjvu_context_t *context)
{
const ddjvu_message_t *message;
const struct ddjvu_message_error_s *error_message;
ddjvu_message_wait(context);
while ((message = ddjvu_message_peek(context)))
{
switch(message->m_any.tag)
{
case DDJVU_ERROR:
error_message = (const struct ddjvu_message_error_s *) message;
fprintf(stderr, "%s, %s:%d: %s\n",
error_message->function,
error_message->filename,
error_message->lineno,
error_message->message
);
exit(EXIT_FAILURE);
break;
default:
break;
}
ddjvu_message_pop(context);
}
}
#define WIDTH 5
#define HEIGHT 5
int main(int argc, char **argv)
{
char buffer[WIDTH * HEIGHT];
int width = WIDTH, height = HEIGHT, x, y;
int rc;
ddjvu_context_t *context;
ddjvu_document_t *document;
ddjvu_format_t *pixel_format;
if (argc != 2)
{
fprintf(stderr, "Usage: %s <djvu-file>\n", argv[0]);
return EXIT_FAILURE;
}
context = ddjvu_context_create(argv[0]);
if (context == NULL)
abort();
document = ddjvu_document_create_by_filename(context, argv[1], 0);
if (document == NULL)
abort();
handle_ddjvu_messages(context);
ddjvu_thumbnail_status(document, 1, 1);
handle_ddjvu_messages(context);
pixel_format = ddjvu_format_create(DDJVU_FORMAT_GREY8, 0, NULL);
rc = ddjvu_thumbnail_render(document, 1, &width, &height, pixel_format, width, buffer);
if (!rc)
abort();
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
unsigned int byte = (unsigned char) buffer[y * WIDTH + x];
printf("%02x ", byte);
}
printf("\n");
}
ddjvu_context_release(context);
}
/* vim:set ts=4 sw=4 et:*/