% Read DjVu Images. %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
#include "MagickCore/constitute.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
+#include "MagickCore/image-private.h"
#include "MagickCore/list.h"
#include "MagickCore/magick.h"
#include "MagickCore/memory_.h"
ddjvu_message_t *message;
/* i might check for a condition! */
+ size=0;
while (!(message = ddjvu_message_peek(lc->context))
&& (size = (size_t) ReadBlob(image,(size_t) blocksize,data)) == blocksize) {
ddjvu_stream_write(lc->document, lc->streamid, (char *) data, size);
* we use the RGB format!
*/
static void
-get_page_image(LoadContext *lc, ddjvu_page_t *page, int x, int y, int w, int h, const ImageInfo *image_info, ExceptionInfo *exception ) {
+get_page_image(LoadContext *lc, ddjvu_page_t *page, int x, int y, int w, int h, ExceptionInfo *exception ) {
ddjvu_format_t
*format;
r+=GetPixelChannels(image);
}
- SyncAuthenticPixels(image,exception);
+ (void) SyncAuthenticPixels(image,exception);
}
}
q=(unsigned char *) RelinquishMagickMemory(q);
%
*/
-static inline double MagickMax(const double x,const double y)
-{
- if (x > y)
- return(x);
- return(y);
-}
-
static Image *ReadOneDJVUImage(LoadContext* lc,const int pagenum,
const ImageInfo *image_info,ExceptionInfo *exception)
{
Image *image;
int logging;
int tag;
+ MagickBooleanType status;
/* so, we know that the page is there! Get its dimension, and */
if (tag == 0) break;
ddjvu_message_pop(lc->context);
} while ((message = ddjvu_message_peek(lc->context)));
+ if (tag == 0) break;
} while (!ddjvu_page_decoding_done(lc->page));
ddjvu_document_get_pageinfo(lc->document, pagenum, &info);
- image->x_resolution = (float) info.dpi;
- image->y_resolution =(float) info.dpi;
+ image->resolution.x = (float) info.dpi;
+ image->resolution.y =(float) info.dpi;
if (image_info->density != (char *) NULL)
{
int
Set rendering resolution.
*/
flags=ParseGeometry(image_info->density,&geometry_info);
- image->x_resolution=geometry_info.rho;
- image->y_resolution=geometry_info.sigma;
+ image->resolution.x=geometry_info.rho;
+ image->resolution.y=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
- image->y_resolution=image->x_resolution;
- info.width*=image->x_resolution/info.dpi;
- info.height*=image->y_resolution/info.dpi;
- info.dpi=(ssize_t) MagickMax(image->x_resolution,image->y_resolution);
+ image->resolution.y=image->resolution.x;
+ info.width*=image->resolution.x/info.dpi;
+ info.height*=image->resolution.y/info.dpi;
+ info.dpi=(ssize_t) MagickMax(image->resolution.x,image->resolution.y);
}
type = ddjvu_page_get_type(lc->page);
/* fixme: MAGICKCORE_QUANTUM_DEPTH ?*/
image->depth = 8UL; /* i only support that? */
- image->matte = MagickTrue;
+ image->alpha_trait = BlendPixelTrait;
/* is this useful? */
}
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
#if DEBUG
printf("now filling %.20g x %.20g\n",(double) image->columns,(double)
image->rows);
#if 1 /* per_line */
/* q = QueueAuthenticPixels(image,0,0,image->columns,image->rows); */
- get_page_image(lc, lc->page, 0, 0, info.width, info.height, image_info,
- exception);
+ get_page_image(lc, lc->page, 0, 0, info.width, info.height, exception);
#else
int i;
for (i = 0;i< image->rows; i++)
* Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter ReadDJVUImage()");
/*
* Initialize members of the MngInfo structure.
*/
- (void) ResetMagickMemory(lc,0,sizeof(LoadContext));
+ (void) memset(lc,0,sizeof(LoadContext));
lc->image = image;
lc->pages = 0;
break;
image->scene=i;
AppendImageToList(&images,CloneImageList(image,exception));
+ images->extent=GetBlobSize(image);
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
}
djvu_close_lc(lc);
- (void) CloseBlob(images);
+ if (images != (Image *) NULL)
+ (void) CloseBlob(images);
if (image != (Image *) NULL)
image=DestroyImageList(image);
ModuleExport size_t RegisterDJVUImage(void)
{
char
- version[MaxTextExtent];
+ version[MagickPathExtent];
MagickInfo
*entry;
*version='\0';
#if defined(DJVU_LIBDJVU_VER_STRING)
- (void) ConcatenateMagickString(version,"libdjvu ",MaxTextExtent);
- (void) ConcatenateMagickString(version,DJVU_LIBDJVU_VER_STRING,MaxTextExtent);
+ (void) ConcatenateMagickString(version,"libdjvu ",MagickPathExtent);
+ (void) ConcatenateMagickString(version,DJVU_LIBDJVU_VER_STRING,MagickPathExtent);
#endif
- entry=SetMagickInfo("DJVU");
+ entry=AcquireMagickInfo("DJVU","DJVU","Deja vu");
#if defined(MAGICKCORE_DJVU_DELEGATE)
entry->decoder=(DecodeImageHandler *) ReadDJVUImage;
#endif
- entry->raw=MagickTrue;
entry->magick=(IsImageFormatHandler *) IsDJVU;
- entry->adjoin=MagickFalse;
- entry->thread_support=MagickTrue;
- entry->description=AcquireString("Déjà vu");
- entry->module=AcquireString("DJVU");
+ entry->flags|=CoderRawSupportFlag;
+ entry->flags^=CoderAdjoinFlag;
if (*version != '\0')
entry->version=AcquireString(version);
entry->note=AcquireString(DJVUNote);