This source file includes following definitions.
- PlasmaPixel
- ReadPlasmaImage
- RegisterPLASMAImage
- UnregisterPLASMAImage
#include "magick/studio.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/cache.h"
#include "magick/channel.h"
#include "magick/constitute.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/fx.h"
#include "magick/image.h"
#include "magick/image-private.h"
#include "magick/list.h"
#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/pixel-accessor.h"
#include "magick/quantum-private.h"
#include "magick/random_.h"
#include "magick/random-private.h"
#include "magick/signature-private.h"
#include "magick/static.h"
#include "magick/string_.h"
#include "magick/module.h"
static inline void PlasmaPixel(Image *image,RandomInfo *random_info,double x,
double y)
{
ExceptionInfo
*exception;
register PixelPacket
*q;
exception=(&image->exception);
q=GetAuthenticPixels(image,(ssize_t) ceil(x-0.5),(ssize_t) ceil(y-0.5),1,1,
exception);
if (q == (PixelPacket *) NULL)
return;
SetPixelRed(q,ScaleShortToQuantum((unsigned short) (65535.0*
GetPseudoRandomValue(random_info)+0.5)));
SetPixelGreen(q,ScaleShortToQuantum((unsigned short) (65535.0*
GetPseudoRandomValue(random_info)+0.5)));
SetPixelBlue(q,ScaleShortToQuantum((unsigned short) (65535.0*
GetPseudoRandomValue(random_info)+0.5)));
(void) SyncAuthenticPixels(image,exception);
}
static Image *ReadPlasmaImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Image
*image;
ImageInfo
*read_info;
MagickBooleanType
status;
register ssize_t
x;
register PixelPacket
*q;
register size_t
i;
SegmentInfo
segment_info;
size_t
depth,
max_depth;
ssize_t
y;
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) FormatLocaleString(read_info->filename,MaxTextExtent,
"gradient:%s",image_info->filename);
image=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
if (image == (Image *) NULL)
return((Image *) NULL);
image->storage_class=DirectClass;
for (y=0; y < (ssize_t) image->rows; y++)
{
q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelOpacity(q,QuantumRange/2);
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
segment_info.x1=0;
segment_info.y1=0;
segment_info.x2=(double) image->columns-1;
segment_info.y2=(double) image->rows-1;
if (LocaleCompare(image_info->filename,"fractal") == 0)
{
RandomInfo
*random_info;
random_info=AcquireRandomInfo();
PlasmaPixel(image,random_info,segment_info.x1,segment_info.y1);
PlasmaPixel(image,random_info,segment_info.x1,(segment_info.y1+
segment_info.y2)/2);
PlasmaPixel(image,random_info,segment_info.x1,segment_info.y2);
PlasmaPixel(image,random_info,(segment_info.x1+segment_info.x2)/2,
segment_info.y1);
PlasmaPixel(image,random_info,(segment_info.x1+segment_info.x2)/2,
(segment_info.y1+segment_info.y2)/2);
PlasmaPixel(image,random_info,(segment_info.x1+segment_info.x2)/2,
segment_info.y2);
PlasmaPixel(image,random_info,segment_info.x2,segment_info.y1);
PlasmaPixel(image,random_info,segment_info.x2,(segment_info.y1+
segment_info.y2)/2);
PlasmaPixel(image,random_info,segment_info.x2,segment_info.y2);
random_info=DestroyRandomInfo(random_info);
}
i=(size_t) MagickMax(image->columns,image->rows)/2;
for (max_depth=0; i != 0; max_depth++)
i>>=1;
for (depth=1; ; depth++)
{
if (PlasmaImage(image,&segment_info,0,depth) != MagickFalse)
break;
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) depth,
max_depth);
if (status == MagickFalse)
break;
}
return(GetFirstImageInList(image));
}
ModuleExport size_t RegisterPLASMAImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("PLASMA");
entry->decoder=(DecodeImageHandler *) ReadPlasmaImage;
entry->adjoin=MagickFalse;
entry->format_type=ImplicitFormatType;
entry->description=ConstantString("Plasma fractal image");
entry->module=ConstantString("PLASMA");
(void) RegisterMagickInfo(entry);
entry=SetMagickInfo("FRACTAL");
entry->decoder=(DecodeImageHandler *) ReadPlasmaImage;
entry->adjoin=MagickFalse;
entry->format_type=ImplicitFormatType;
entry->description=ConstantString("Plasma fractal image");
entry->module=ConstantString("PLASMA");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
ModuleExport void UnregisterPLASMAImage(void)
{
(void) UnregisterMagickInfo("FRACTAL");
(void) UnregisterMagickInfo("PLASMA");
}