This source file includes following definitions.
- ReadGRADIENTImage
- RegisterGRADIENTImage
- UnregisterGRADIENTImage
#include "magick/studio.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/channel.h"
#include "magick/color.h"
#include "magick/color-private.h"
#include "magick/colorspace-private.h"
#include "magick/draw.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/image.h"
#include "magick/image-private.h"
#include "magick/list.h"
#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/paint.h"
#include "magick/pixel-accessor.h"
#include "magick/pixel-private.h"
#include "magick/quantum-private.h"
#include "magick/static.h"
#include "magick/string_.h"
#include "magick/module.h"
#include "magick/studio.h"
static Image *ReadGRADIENTImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
colorname[MaxTextExtent+4];
Image
*image;
ImageInfo
*read_info;
MagickBooleanType
icc_color,
status;
MagickPixelPacket
start_pixel,
stop_pixel;
PixelPacket
start_color,
stop_color;
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);
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) CopyMagickString(colorname,image_info->filename,MaxTextExtent);
(void) sscanf(image_info->filename,"%[^-]",colorname);
(void) FormatLocaleString(read_info->filename,MaxTextExtent,"xc:%s",
colorname);
image=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
if (image == (Image *) NULL)
return((Image *) NULL);
(void) SetImageOpacity(image,(Quantum) TransparentOpacity);
(void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
icc_color=MagickFalse;
if (LocaleCompare(colorname,"icc") == 0)
{
(void) ConcatenateMagickString(colorname,"-",MaxTextExtent);
(void) sscanf(image_info->filename,"%*[^-]-%[^-]",colorname+4);
icc_color=MagickTrue;
}
if (QueryColorDatabase(colorname,&start_color,exception) == MagickFalse)
{
image=DestroyImage(image);
return((Image *) NULL);
}
(void) QueryMagickColor(colorname,&start_pixel,exception);
(void) CopyMagickString(colorname,"white",MaxTextExtent);
if (GetPixelLuma(image,&start_color) > (QuantumRange/2.0))
(void) CopyMagickString(colorname,"black",MaxTextExtent);
if (icc_color == MagickFalse)
(void) sscanf(image_info->filename,"%*[^-]-%[^-]",colorname);
else
(void) sscanf(image_info->filename,"%*[^-]-%*[^-]-%[^-]",colorname);
if (QueryColorDatabase(colorname,&stop_color,exception) == MagickFalse)
{
image=DestroyImage(image);
return((Image *) NULL);
}
(void) QueryMagickColor(colorname,&stop_pixel,exception);
(void) SetImageColorspace(image,start_pixel.colorspace);
image->matte=start_pixel.matte;
if (stop_pixel.matte != MagickFalse)
image->matte=MagickTrue;
status=GradientImage(image,LocaleCompare(image_info->magick,"GRADIENT") == 0 ?
LinearGradient : RadialGradient,PadSpread,&start_color,&stop_color);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
return(GetFirstImageInList(image));
}
ModuleExport size_t RegisterGRADIENTImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("GRADIENT");
entry->decoder=(DecodeImageHandler *) ReadGRADIENTImage;
entry->adjoin=MagickFalse;
entry->raw=MagickTrue;
entry->format_type=ImplicitFormatType;
entry->description=ConstantString("Gradual linear passing from one shade to "
"another");
entry->module=ConstantString("GRADIENT");
(void) RegisterMagickInfo(entry);
entry=SetMagickInfo("RADIAL-GRADIENT");
entry->decoder=(DecodeImageHandler *) ReadGRADIENTImage;
entry->adjoin=MagickFalse;
entry->raw=MagickTrue;
entry->format_type=ImplicitFormatType;
entry->description=ConstantString("Gradual radial passing from one shade to "
"another");
entry->module=ConstantString("GRADIENT");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
ModuleExport void UnregisterGRADIENTImage(void)
{
(void) UnregisterMagickInfo("RADIAL-GRADIENT");
(void) UnregisterMagickInfo("GRADIENT");
}