| 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/color.h" |
|---|
| 46 | #include "magick/color-private.h" |
|---|
| 47 | #include "magick/draw.h" |
|---|
| 48 | #include "magick/exception.h" |
|---|
| 49 | #include "magick/exception-private.h" |
|---|
| 50 | #include "magick/image.h" |
|---|
| 51 | #include "magick/image-private.h" |
|---|
| 52 | #include "magick/list.h" |
|---|
| 53 | #include "magick/magick.h" |
|---|
| 54 | #include "magick/memory_.h" |
|---|
| 55 | #include "magick/paint.h" |
|---|
| 56 | #include "magick/pixel-private.h" |
|---|
| 57 | #include "magick/quantum-private.h" |
|---|
| 58 | #include "magick/static.h" |
|---|
| 59 | #include "magick/string_.h" |
|---|
| 60 | #include "magick/module.h" |
|---|
| 61 | #include "magick/studio.h" |
|---|
| 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 | |
|---|
| 90 | |
|---|
| 91 | static Image *ReadGRADIENTImage(const ImageInfo *image_info, |
|---|
| 92 | ExceptionInfo *exception) |
|---|
| 93 | { |
|---|
| 94 | char |
|---|
| 95 | colorname[MaxTextExtent]; |
|---|
| 96 | |
|---|
| 97 | PixelPacket |
|---|
| 98 | start_color, |
|---|
| 99 | stop_color; |
|---|
| 100 | |
|---|
| 101 | Image |
|---|
| 102 | *image; |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | assert(image_info != (const ImageInfo *) NULL); |
|---|
| 108 | assert(image_info->signature == MagickSignature); |
|---|
| 109 | if (image_info->debug != MagickFalse) |
|---|
| 110 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
|---|
| 111 | image_info->filename); |
|---|
| 112 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 113 | assert(exception->signature == MagickSignature); |
|---|
| 114 | image=AcquireImage(image_info); |
|---|
| 115 | if ((image->columns == 0) || (image->rows == 0)) |
|---|
| 116 | ThrowReaderException(OptionError,"MustSpecifyImageSize"); |
|---|
| 117 | if (SetImageExtent(image,0,0) == MagickFalse) |
|---|
| 118 | { |
|---|
| 119 | InheritException(exception,&image->exception); |
|---|
| 120 | return(DestroyImageList(image)); |
|---|
| 121 | } |
|---|
| 122 | (void) SetImageOpacity(image,(Quantum) TransparentOpacity); |
|---|
| 123 | (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent); |
|---|
| 124 | (void) CopyMagickString(colorname,image_info->filename,MaxTextExtent); |
|---|
| 125 | (void) sscanf(image_info->filename,"%[^-]",colorname); |
|---|
| 126 | if (QueryColorDatabase(colorname,&start_color,exception) == MagickFalse) |
|---|
| 127 | { |
|---|
| 128 | image=DestroyImage(image); |
|---|
| 129 | return((Image *) NULL); |
|---|
| 130 | } |
|---|
| 131 | (void) CopyMagickString(colorname,"white",MaxTextExtent); |
|---|
| 132 | if (PixelIntensityToQuantum(&start_color) > (Quantum) (QuantumRange/2)) |
|---|
| 133 | (void) CopyMagickString(colorname,"black",MaxTextExtent); |
|---|
| 134 | (void) sscanf(image_info->filename,"%*[^-]-%s",colorname); |
|---|
| 135 | if (QueryColorDatabase(colorname,&stop_color,exception) == MagickFalse) |
|---|
| 136 | { |
|---|
| 137 | image=DestroyImage(image); |
|---|
| 138 | return((Image *) NULL); |
|---|
| 139 | } |
|---|
| 140 | (void) GradientImage(image,LocaleCompare(image_info->magick,"GRADIENT") == 0 ? |
|---|
| 141 | LinearGradient : RadialGradient,ReflectSpread,&start_color,&stop_color); |
|---|
| 142 | return(GetFirstImageInList(image)); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | ModuleExport unsigned long RegisterGRADIENTImage(void) |
|---|
| 169 | { |
|---|
| 170 | MagickInfo |
|---|
| 171 | *entry; |
|---|
| 172 | |
|---|
| 173 | entry=SetMagickInfo("GRADIENT"); |
|---|
| 174 | entry->decoder=(DecodeImageHandler *) ReadGRADIENTImage; |
|---|
| 175 | entry->adjoin=MagickFalse; |
|---|
| 176 | entry->raw=MagickTrue; |
|---|
| 177 | entry->endian_support=MagickTrue; |
|---|
| 178 | entry->format_type=ImplicitFormatType; |
|---|
| 179 | entry->description=ConstantString("Gradual linear passing from one shade to " |
|---|
| 180 | "another"); |
|---|
| 181 | entry->module=ConstantString("GRADIENT"); |
|---|
| 182 | (void) RegisterMagickInfo(entry); |
|---|
| 183 | entry=SetMagickInfo("RADIAL-GRADIENT"); |
|---|
| 184 | entry->decoder=(DecodeImageHandler *) ReadGRADIENTImage; |
|---|
| 185 | entry->adjoin=MagickFalse; |
|---|
| 186 | entry->raw=MagickTrue; |
|---|
| 187 | entry->endian_support=MagickTrue; |
|---|
| 188 | entry->format_type=ImplicitFormatType; |
|---|
| 189 | entry->description=ConstantString("Gradual radial passing from one shade to " |
|---|
| 190 | "another"); |
|---|
| 191 | entry->module=ConstantString("GRADIENT"); |
|---|
| 192 | (void) RegisterMagickInfo(entry); |
|---|
| 193 | return(MagickImageCoderSignature); |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | ModuleExport void UnregisterGRADIENTImage(void) |
|---|
| 216 | { |
|---|
| 217 | (void) UnregisterMagickInfo("RADIAL-GRADIENT"); |
|---|
| 218 | (void) UnregisterMagickInfo("GRADIENT"); |
|---|
| 219 | } |
|---|