This source file includes following definitions.
- ReadVIDImage
- RegisterVIDImage
- UnregisterVIDImage
- WriteVIDImage
#include "magick/studio.h"
#include "magick/property.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/constitute.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/geometry.h"
#include "magick/image.h"
#include "magick/image-private.h"
#include "magick/list.h"
#include "magick/log.h"
#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/montage.h"
#include "magick/pixel-accessor.h"
#include "magick/quantum-private.h"
#include "magick/resize.h"
#include "magick/static.h"
#include "magick/string_.h"
#include "magick/module.h"
#include "magick/utility.h"
static MagickBooleanType
WriteVIDImage(const ImageInfo *,Image *);
static Image *ReadVIDImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
#define ClientName "montage"
char
**filelist,
*label;
Image
*image,
*images,
*montage_image,
*next_image,
*thumbnail_image;
ImageInfo
*read_info;
int
number_files;
MagickBooleanType
status;
MontageInfo
*montage_info;
RectangleInfo
geometry;
register ssize_t
i;
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
filelist=(char **) AcquireMagickMemory(sizeof(*filelist));
if (filelist == (char **) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
filelist[0]=ConstantString(image_info->filename);
number_files=1;
status=ExpandFilenames(&number_files,&filelist);
if ((status == MagickFalse) || (number_files == 0))
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
image=DestroyImage(image);
images=NewImageList();
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL,
(void *) NULL);
if (read_info->size == (char *) NULL)
(void) CloneString(&read_info->size,DefaultTileGeometry);
for (i=0; i < (ssize_t) number_files; i++)
{
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"name: %s",
filelist[i]);
(void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent);
filelist[i]=DestroyString(filelist[i]);
*read_info->magick='\0';
next_image=ReadImage(read_info,exception);
CatchException(exception);
if (next_image == (Image *) NULL)
break;
label=InterpretImageProperties(image_info,next_image,DefaultTileLabel);
(void) SetImageProperty(next_image,"label",label);
label=DestroyString(label);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"geometry: %.20gx%.20g",(double) next_image->columns,(double)
next_image->rows);
SetGeometry(next_image,&geometry);
(void) ParseMetaGeometry(read_info->size,&geometry.x,&geometry.y,
&geometry.width,&geometry.height);
thumbnail_image=ThumbnailImage(next_image,geometry.width,geometry.height,
exception);
if (thumbnail_image != (Image *) NULL)
{
next_image=DestroyImage(next_image);
next_image=thumbnail_image;
}
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"thumbnail geometry: %.20gx%.20g",(double) next_image->columns,(double)
next_image->rows);
AppendImageToList(&images,next_image);
status=SetImageProgress(images,LoadImagesTag,i,number_files);
if (status == MagickFalse)
break;
}
read_info=DestroyImageInfo(read_info);
filelist=(char **) RelinquishMagickMemory(filelist);
if (images == (Image *) NULL)
ThrowReaderException(CorruptImageError,
"ImageFileDoesNotContainAnyImageData");
montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"creating montage");
montage_image=MontageImageList(image_info,montage_info,
GetFirstImageInList(images),exception);
montage_info=DestroyMontageInfo(montage_info);
images=DestroyImageList(images);
return(montage_image);
}
ModuleExport size_t RegisterVIDImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("VID");
entry->decoder=(DecodeImageHandler *) ReadVIDImage;
entry->encoder=(EncodeImageHandler *) WriteVIDImage;
entry->format_type=ImplicitFormatType;
entry->description=ConstantString("Visual Image Directory");
entry->module=ConstantString("VID");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
ModuleExport void UnregisterVIDImage(void)
{
(void) UnregisterMagickInfo("VID");
}
static MagickBooleanType WriteVIDImage(const ImageInfo *image_info,Image *image)
{
Image
*montage_image;
ImageInfo
*write_info;
MagickBooleanType
status;
MontageInfo
*montage_info;
register Image
*p;
for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
(void) SetImageProperty(p,"label",DefaultTileLabel);
montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
montage_image=MontageImageList(image_info,montage_info,image,
&image->exception);
montage_info=DestroyMontageInfo(montage_info);
if (montage_image == (Image *) NULL)
return(MagickFalse);
(void) CopyMagickString(montage_image->filename,image_info->filename,
MaxTextExtent);
write_info=CloneImageInfo(image_info);
*write_info->magick='\0';
(void) SetImageInfo(write_info,1,&image->exception);
if (LocaleCompare(write_info->magick,"VID") == 0)
(void) FormatLocaleString(montage_image->filename,MaxTextExtent,
"miff:%s",write_info->filename);
status=WriteImage(write_info,montage_image);
montage_image=DestroyImage(montage_image);
write_info=DestroyImageInfo(write_info);
return(status);
}