| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | #include "magick/studio.h" |
|---|
| 43 | #include "magick/blob.h" |
|---|
| 44 | #include "magick/blob-private.h" |
|---|
| 45 | #include "magick/constitute.h" |
|---|
| 46 | #include "magick/exception.h" |
|---|
| 47 | #include "magick/exception-private.h" |
|---|
| 48 | #include "magick/image.h" |
|---|
| 49 | #include "magick/image-private.h" |
|---|
| 50 | #include "magick/list.h" |
|---|
| 51 | #include "magick/magick.h" |
|---|
| 52 | #include "magick/memory_.h" |
|---|
| 53 | #include "magick/monitor.h" |
|---|
| 54 | #include "magick/monitor-private.h" |
|---|
| 55 | #include "magick/random_.h" |
|---|
| 56 | #include "magick/signature-private.h" |
|---|
| 57 | #include "magick/quantum-private.h" |
|---|
| 58 | #include "magick/static.h" |
|---|
| 59 | #include "magick/string_.h" |
|---|
| 60 | #include "magick/module.h" |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | static inline size_t MagickMax(const size_t x,const size_t y) |
|---|
| 90 | { |
|---|
| 91 | if (x > y) |
|---|
| 92 | return(x); |
|---|
| 93 | return(y); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | static inline void PlasmaPixel(Image *image,double x,double y) |
|---|
| 97 | { |
|---|
| 98 | QuantumAny |
|---|
| 99 | scale; |
|---|
| 100 | |
|---|
| 101 | register PixelPacket |
|---|
| 102 | *q; |
|---|
| 103 | |
|---|
| 104 | q=GetImagePixels(image,(long) ceil(x-0.5),(long) ceil(y-0.5),1,1); |
|---|
| 105 | if (q == (PixelPacket *) NULL) |
|---|
| 106 | return; |
|---|
| 107 | scale=GetQuantumScale(16UL); |
|---|
| 108 | q->red=ScaleAnyToQuantum((unsigned long) (65535.0*GetPseudoRandomValue()+ |
|---|
| 109 | 0.5),16UL,scale); |
|---|
| 110 | q->green=ScaleAnyToQuantum((unsigned long) (65535.0*GetPseudoRandomValue()+ |
|---|
| 111 | 0.5),16UL,scale); |
|---|
| 112 | q->blue=ScaleAnyToQuantum((unsigned long) (65535.0*GetPseudoRandomValue()+ |
|---|
| 113 | 0.5),16UL,scale); |
|---|
| 114 | (void) SyncImagePixels(image); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | static Image *ReadPlasmaImage(const ImageInfo *image_info, |
|---|
| 118 | ExceptionInfo *exception) |
|---|
| 119 | { |
|---|
| 120 | Image |
|---|
| 121 | *image; |
|---|
| 122 | |
|---|
| 123 | ImageInfo |
|---|
| 124 | *read_info; |
|---|
| 125 | |
|---|
| 126 | long |
|---|
| 127 | y; |
|---|
| 128 | |
|---|
| 129 | MagickBooleanType |
|---|
| 130 | status; |
|---|
| 131 | |
|---|
| 132 | register long |
|---|
| 133 | x; |
|---|
| 134 | |
|---|
| 135 | register PixelPacket |
|---|
| 136 | *q; |
|---|
| 137 | |
|---|
| 138 | register unsigned long |
|---|
| 139 | i; |
|---|
| 140 | |
|---|
| 141 | SegmentInfo |
|---|
| 142 | segment_info; |
|---|
| 143 | |
|---|
| 144 | unsigned long |
|---|
| 145 | depth, |
|---|
| 146 | max_depth; |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | read_info=CloneImageInfo(image_info); |
|---|
| 152 | SetImageInfoBlob(read_info,(void *) NULL,0); |
|---|
| 153 | (void) FormatMagickString(read_info->filename,MaxTextExtent, |
|---|
| 154 | "gradient:%s",image_info->filename); |
|---|
| 155 | image=ReadImage(read_info,exception); |
|---|
| 156 | read_info=DestroyImageInfo(read_info); |
|---|
| 157 | if (image == (Image *) NULL) |
|---|
| 158 | return((Image *) NULL); |
|---|
| 159 | image->storage_class=DirectClass; |
|---|
| 160 | for (y=0; y < (long) image->rows; y++) |
|---|
| 161 | { |
|---|
| 162 | q=GetImagePixels(image,0,y,image->columns,1); |
|---|
| 163 | if (q == (PixelPacket *) NULL) |
|---|
| 164 | break; |
|---|
| 165 | for (x=0; x < (long) image->columns; x++) |
|---|
| 166 | { |
|---|
| 167 | q->opacity=(Quantum) (QuantumRange/2); |
|---|
| 168 | q++; |
|---|
| 169 | } |
|---|
| 170 | if (SyncImagePixels(image) == MagickFalse) |
|---|
| 171 | break; |
|---|
| 172 | } |
|---|
| 173 | segment_info.x1=0; |
|---|
| 174 | segment_info.y1=0; |
|---|
| 175 | segment_info.x2=(double) image->columns-1; |
|---|
| 176 | segment_info.y2=(double) image->rows-1; |
|---|
| 177 | if (LocaleCompare(image_info->filename,"fractal") == 0) |
|---|
| 178 | { |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | PlasmaPixel(image,segment_info.x1,segment_info.y1); |
|---|
| 183 | PlasmaPixel(image,segment_info.x1,(segment_info.y1+segment_info.y2)/2); |
|---|
| 184 | PlasmaPixel(image,segment_info.x1,segment_info.y2); |
|---|
| 185 | PlasmaPixel(image,(segment_info.x1+segment_info.x2)/2,segment_info.y1); |
|---|
| 186 | PlasmaPixel(image,(segment_info.x1+segment_info.x2)/2, |
|---|
| 187 | (segment_info.y1+segment_info.y2)/2); |
|---|
| 188 | PlasmaPixel(image,(segment_info.x1+segment_info.x2)/2,segment_info.y2); |
|---|
| 189 | PlasmaPixel(image,segment_info.x2,segment_info.y1); |
|---|
| 190 | PlasmaPixel(image,segment_info.x2,(segment_info.y1+segment_info.y2)/2); |
|---|
| 191 | PlasmaPixel(image,segment_info.x2,segment_info.y2); |
|---|
| 192 | } |
|---|
| 193 | i=(unsigned long) MagickMax(image->columns,image->rows)/2; |
|---|
| 194 | for (max_depth=0; i != 0; max_depth++) |
|---|
| 195 | i>>=1; |
|---|
| 196 | for (depth=1; ; depth++) |
|---|
| 197 | { |
|---|
| 198 | if (PlasmaImage(image,&segment_info,0,depth) != MagickFalse) |
|---|
| 199 | break; |
|---|
| 200 | status=SetImageProgress(image,LoadImageTag,depth,max_depth); |
|---|
| 201 | if (status == MagickFalse) |
|---|
| 202 | break; |
|---|
| 203 | } |
|---|
| 204 | (void) SetImageAlphaChannel(image,DeactivateAlphaChannel); |
|---|
| 205 | return(GetFirstImageInList(image)); |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | ModuleExport unsigned long RegisterPLASMAImage(void) |
|---|
| 232 | { |
|---|
| 233 | MagickInfo |
|---|
| 234 | *entry; |
|---|
| 235 | |
|---|
| 236 | entry=SetMagickInfo("PLASMA"); |
|---|
| 237 | entry->decoder=(DecodeImageHandler *) ReadPlasmaImage; |
|---|
| 238 | entry->adjoin=MagickFalse; |
|---|
| 239 | entry->format_type=ImplicitFormatType; |
|---|
| 240 | entry->description=ConstantString("Plasma fractal image"); |
|---|
| 241 | entry->module=ConstantString("PLASMA"); |
|---|
| 242 | (void) RegisterMagickInfo(entry); |
|---|
| 243 | entry=SetMagickInfo("FRACTAL"); |
|---|
| 244 | entry->decoder=(DecodeImageHandler *) ReadPlasmaImage; |
|---|
| 245 | entry->adjoin=MagickFalse; |
|---|
| 246 | entry->format_type=ImplicitFormatType; |
|---|
| 247 | entry->description=ConstantString("Plasma fractal image"); |
|---|
| 248 | entry->module=ConstantString("PLASMA"); |
|---|
| 249 | (void) RegisterMagickInfo(entry); |
|---|
| 250 | return(MagickImageCoderSignature); |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | |
|---|
| 267 | |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | ModuleExport void UnregisterPLASMAImage(void) |
|---|
| 273 | { |
|---|
| 274 | (void) UnregisterMagickInfo("FRACTAL"); |
|---|
| 275 | (void) UnregisterMagickInfo("PLASMA"); |
|---|
| 276 | } |
|---|