% MagickCore Methods to Consitute an Image %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% October 1998 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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 %
Include declarations.
*/
#include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
#include "MagickCore/blob.h"
#include "MagickCore/blob-private.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/cache.h"
#include "MagickCore/client.h"
+#include "MagickCore/colorspace-private.h"
#include "MagickCore/constitute.h"
#include "MagickCore/constitute-private.h"
#include "MagickCore/delegate.h"
#include "MagickCore/utility.h"
#include "MagickCore/utility-private.h"
\f
-static SemaphoreInfo
- *constitute_semaphore = (SemaphoreInfo *) NULL;
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ C o n s t i t u t e C o m p o n e n t G e n e s i s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% ConstituteComponentGenesis() instantiates the constitute component.
-%
-% The format of the ConstituteComponentGenesis method is:
-%
-% MagickBooleanType ConstituteComponentGenesis(void)
-%
-*/
-MagickPrivate MagickBooleanType ConstituteComponentGenesis(void)
-{
- AcquireSemaphoreInfo(&constitute_semaphore);
- return(MagickTrue);
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ C o n s t i t u t e C o m p o n e n t T e r m i n u s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% ConstituteComponentTerminus() destroys the constitute component.
-%
-% The format of the ConstituteComponentTerminus method is:
-%
-% ConstituteComponentTerminus(void)
-%
-*/
-MagickPrivate void ConstituteComponentTerminus(void)
-{
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
- DestroySemaphoreInfo(&constitute_semaphore);
-}
-\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
sans=AcquireExceptionInfo();
(void) SetImageInfo(read_info,0,sans);
sans=DestroyExceptionInfo(sans);
+ if (read_info->number_scenes == 0)
+ {
+ read_info=DestroyImageInfo(read_info);
+ return(PingImage(image_info,exception));
+ }
(void) CopyMagickString(ping_filename,read_info->filename,MaxTextExtent);
images=NewImageList();
extent=(ssize_t) (read_info->scene+read_info->number_scenes);
{
errno=EPERM;
(void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
- "NotAuthorized","'%s'",read_info->filename);
+ "NotAuthorized","`%s'",read_info->filename);
+ read_info=DestroyImageInfo(read_info);
return((Image *) NULL);
}
- if ((LocaleNCompare(filename,"fd:",3) == 0) &&
- (image_info->file == (FILE *) NULL))
- {
- read_info->file=fdopen(StringToLong(filename+3),"rb");
- SetImageInfoFile((ImageInfo *) image_info,read_info->file);
- }
/*
Call appropriate image reader based on image type.
*/
image=DestroyImage(image);
}
image=NewImageList();
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
if ((magick_info == (const MagickInfo *) NULL) ||
(GetImageDecoder(magick_info) == (DecodeImageHandler *) NULL))
{
{
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & DecoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(magick_info->semaphore);
image=GetImageDecoder(magick_info)(read_info,exception);
if ((thread_support & DecoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
else
{
if (delegate_info == (const DelegateInfo *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- MissingDelegateError,"NoDecodeDelegateForThisImageFormat","'%s'",
- read_info->filename);
+ MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
+ read_info->magick);
if (read_info->temporary != MagickFalse)
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
MaxTextExtent);
*read_info->filename='\0';
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(delegate_info->semaphore);
(void) InvokeDelegate(read_info,image,read_info->magick,(char *) NULL,
exception);
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(delegate_info->semaphore);
image=DestroyImageList(image);
read_info->temporary=MagickTrue;
(void) SetImageInfo(read_info,0,exception);
{
if (IsPathAccessible(read_info->filename) != MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
- MissingDelegateError,"NoDecodeDelegateForThisImageFormat","'%s'",
- read_info->filename);
+ MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
+ read_info->magick);
else
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
read_info->filename);
}
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & DecoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(magick_info->semaphore);
image=(Image *) (GetImageDecoder(magick_info))(read_info,exception);
if ((thread_support & DecoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
if (read_info->temporary != MagickFalse)
{
clones=CloneImages(image,read_info->scenes,exception);
if (clones == (Image *) NULL)
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
- "SubimageSpecificationReturnsNoImages","'%s'",read_info->filename);
+ "SubimageSpecificationReturnsNoImages","`%s'",read_info->filename);
else
{
image=DestroyImageList(image);
}
}
if (GetBlobError(image) != MagickFalse)
- {
- ThrowFileException(exception,FileOpenError,
- "AnErrorHasOccurredReadingFromFile",read_info->filename);
- image=DestroyImageList(image);
- read_info=DestroyImageInfo(read_info);
- return((Image *) NULL);
- }
+ ThrowFileException(exception,FileOpenError,
+ "AnErrorHasOccurredReadingFromFile",read_info->filename);
for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
{
char
if (IsRightsAuthorized(domain,rights,write_info->magick) == MagickFalse)
{
sans_exception=DestroyExceptionInfo(sans_exception);
+ write_info=DestroyImageInfo(write_info);
errno=EPERM;
ThrowBinaryException(PolicyError,"NotAuthorized",filename);
}
- if ((LocaleNCompare(filename,"fd:",3) == 0) &&
- (image_info->file == (FILE *) NULL))
- {
- write_info->file=fdopen(StringToLong(filename+3),"wb");
- SetImageInfoFile((ImageInfo *) image_info,write_info->file);
- }
/*
Call appropriate image reader based on image type.
*/
(void) CloseBlob(image);
}
}
- if (constitute_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&constitute_semaphore);
if ((magick_info != (const MagickInfo *) NULL) &&
(GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
{
*/
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & EncoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(magick_info->semaphore);
status=GetImageEncoder(magick_info)(write_info,image,exception);
if ((thread_support & EncoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
else
{
*/
*write_info->filename='\0';
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(delegate_info->semaphore);
status=InvokeDelegate(write_info,image,(char *) NULL,
write_info->magick,exception);
if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(delegate_info->semaphore);
(void) CopyMagickString(image->filename,filename,MaxTextExtent);
}
else
(GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoEncodeDelegateForThisImageFormat",
- "'%s'",image->filename);
+ "`%s'",write_info->magick);
else
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateWarning,"NoEncodeDelegateForThisImageFormat",
- "'%s'",image->filename);
+ "`%s'",write_info->magick);
}
if ((magick_info != (const MagickInfo *) NULL) &&
(GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
*/
thread_support=GetMagickThreadSupport(magick_info);
if ((thread_support & EncoderThreadSupport) == 0)
- LockSemaphoreInfo(constitute_semaphore);
+ LockSemaphoreInfo(magick_info->semaphore);
status=GetImageEncoder(magick_info)(write_info,image,exception);
if ((thread_support & EncoderThreadSupport) == 0)
- UnlockSemaphoreInfo(constitute_semaphore);
+ UnlockSemaphoreInfo(magick_info->semaphore);
}
}
}
if (GetBlobError(image) != MagickFalse)
ThrowFileException(exception,FileOpenError,
"AnErrorHasOccurredWritingToFile",image->filename);
- if (temporary == MagickTrue)
+ if (temporary != MagickFalse)
{
/*
Copy temporary image file to permanent.