| 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/exception.h" |
|---|
| 46 | #include "magick/exception-private.h" |
|---|
| 47 | #include "magick/image.h" |
|---|
| 48 | #include "magick/image-private.h" |
|---|
| 49 | #include "magick/list.h" |
|---|
| 50 | #include "magick/magick.h" |
|---|
| 51 | #include "magick/memory_.h" |
|---|
| 52 | #include "magick/monitor.h" |
|---|
| 53 | #include "magick/monitor-private.h" |
|---|
| 54 | #include "magick/quantum-private.h" |
|---|
| 55 | #include "magick/static.h" |
|---|
| 56 | #include "magick/string_.h" |
|---|
| 57 | #include "magick/module.h" |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 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 | static MagickBooleanType IsSCT(const unsigned char *magick,const size_t length) |
|---|
| 86 | { |
|---|
| 87 | if (length < 2) |
|---|
| 88 | return(MagickFalse); |
|---|
| 89 | if (LocaleNCompare((char *) magick,"CT",2) == 0) |
|---|
| 90 | return(MagickTrue); |
|---|
| 91 | return(MagickFalse); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception) |
|---|
| 121 | { |
|---|
| 122 | char |
|---|
| 123 | magick[2]; |
|---|
| 124 | |
|---|
| 125 | Image |
|---|
| 126 | *image; |
|---|
| 127 | |
|---|
| 128 | long |
|---|
| 129 | y; |
|---|
| 130 | |
|---|
| 131 | MagickBooleanType |
|---|
| 132 | status; |
|---|
| 133 | |
|---|
| 134 | MagickRealType |
|---|
| 135 | height, |
|---|
| 136 | width; |
|---|
| 137 | |
|---|
| 138 | Quantum |
|---|
| 139 | pixel; |
|---|
| 140 | |
|---|
| 141 | register IndexPacket |
|---|
| 142 | *indexes; |
|---|
| 143 | |
|---|
| 144 | register long |
|---|
| 145 | i, |
|---|
| 146 | x; |
|---|
| 147 | |
|---|
| 148 | register PixelPacket |
|---|
| 149 | *q; |
|---|
| 150 | |
|---|
| 151 | ssize_t |
|---|
| 152 | count; |
|---|
| 153 | |
|---|
| 154 | unsigned char |
|---|
| 155 | buffer[768]; |
|---|
| 156 | |
|---|
| 157 | unsigned long |
|---|
| 158 | separations, |
|---|
| 159 | separations_mask, |
|---|
| 160 | units; |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | assert(image_info != (const ImageInfo *) NULL); |
|---|
| 166 | assert(image_info->signature == MagickSignature); |
|---|
| 167 | if (image_info->debug != MagickFalse) |
|---|
| 168 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
|---|
| 169 | image_info->filename); |
|---|
| 170 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 171 | assert(exception->signature == MagickSignature); |
|---|
| 172 | image=AcquireImage(image_info); |
|---|
| 173 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
|---|
| 174 | if (status == MagickFalse) |
|---|
| 175 | { |
|---|
| 176 | image=DestroyImageList(image); |
|---|
| 177 | return((Image *) NULL); |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | count=ReadBlob(image,80,buffer); |
|---|
| 183 | count=ReadBlob(image,2,(unsigned char *) magick); |
|---|
| 184 | if ((LocaleNCompare((char *) magick,"CT",2) != 0) && |
|---|
| 185 | (LocaleNCompare((char *) magick,"LW",2) != 0) && |
|---|
| 186 | (LocaleNCompare((char *) magick,"BM",2) != 0) && |
|---|
| 187 | (LocaleNCompare((char *) magick,"PG",2) != 0) && |
|---|
| 188 | (LocaleNCompare((char *) magick,"TX",2) != 0)) |
|---|
| 189 | ThrowReaderException(CorruptImageError,"ImproperImageHeader"); |
|---|
| 190 | if ((LocaleNCompare((char *) magick,"LW",2) == 0) || |
|---|
| 191 | (LocaleNCompare((char *) magick,"BM",2) == 0) || |
|---|
| 192 | (LocaleNCompare((char *) magick,"PG",2) == 0) || |
|---|
| 193 | (LocaleNCompare((char *) magick,"TX",2) == 0)) |
|---|
| 194 | ThrowReaderException(CoderError,"OnlyContinuousTonePictureSupported"); |
|---|
| 195 | count=ReadBlob(image,174,buffer); |
|---|
| 196 | count=ReadBlob(image,768,buffer); |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | units=1UL*ReadBlobByte(image); |
|---|
| 201 | if (units == 0) |
|---|
| 202 | image->units=PixelsPerCentimeterResolution; |
|---|
| 203 | separations=1UL*ReadBlobByte(image); |
|---|
| 204 | separations_mask=ReadBlobMSBShort(image); |
|---|
| 205 | count=ReadBlob(image,14,buffer); |
|---|
| 206 | buffer[14]='\0'; |
|---|
| 207 | height=atof((char *) buffer); |
|---|
| 208 | count=ReadBlob(image,14,buffer); |
|---|
| 209 | width=atof((char *) buffer); |
|---|
| 210 | count=ReadBlob(image,12,buffer); |
|---|
| 211 | buffer[12]='\0'; |
|---|
| 212 | image->rows=1UL*atol((char *) buffer); |
|---|
| 213 | count=ReadBlob(image,12,buffer); |
|---|
| 214 | image->columns=1UL*atol((char *) buffer); |
|---|
| 215 | count=ReadBlob(image,200,buffer); |
|---|
| 216 | count=ReadBlob(image,768,buffer); |
|---|
| 217 | if (separations_mask == 0x0f) |
|---|
| 218 | image->colorspace=CMYKColorspace; |
|---|
| 219 | image->x_resolution=1.0*image->columns/width; |
|---|
| 220 | image->y_resolution=1.0*image->rows/height; |
|---|
| 221 | if (image_info->ping != MagickFalse) |
|---|
| 222 | { |
|---|
| 223 | (void) CloseBlob(image); |
|---|
| 224 | return(GetFirstImageInList(image)); |
|---|
| 225 | } |
|---|
| 226 | if (SetImageExtent(image,0,0) == MagickFalse) |
|---|
| 227 | { |
|---|
| 228 | InheritException(exception,&image->exception); |
|---|
| 229 | return(DestroyImageList(image)); |
|---|
| 230 | } |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | for (y=0; y < (long) image->rows; y++) |
|---|
| 235 | { |
|---|
| 236 | for (i=0; i < (long) separations; i++) |
|---|
| 237 | { |
|---|
| 238 | q=GetImagePixels(image,0,y,image->columns,1); |
|---|
| 239 | if (q == (PixelPacket *) NULL) |
|---|
| 240 | break; |
|---|
| 241 | indexes=GetIndexes(image); |
|---|
| 242 | for (x=0; x < (long) image->columns; x++) |
|---|
| 243 | { |
|---|
| 244 | pixel=(Quantum) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); |
|---|
| 245 | if (image->colorspace == CMYKColorspace) |
|---|
| 246 | pixel=(Quantum) (QuantumRange-pixel); |
|---|
| 247 | switch (i) |
|---|
| 248 | { |
|---|
| 249 | case 0: |
|---|
| 250 | { |
|---|
| 251 | q->red=pixel; |
|---|
| 252 | q->green=pixel; |
|---|
| 253 | q->blue=pixel; |
|---|
| 254 | break; |
|---|
| 255 | } |
|---|
| 256 | case 1: |
|---|
| 257 | { |
|---|
| 258 | q->green=pixel; |
|---|
| 259 | break; |
|---|
| 260 | } |
|---|
| 261 | case 2: |
|---|
| 262 | { |
|---|
| 263 | q->blue=pixel; break; |
|---|
| 264 | break; |
|---|
| 265 | } |
|---|
| 266 | case 3: |
|---|
| 267 | { |
|---|
| 268 | if (image->colorspace == CMYKColorspace) |
|---|
| 269 | indexes[x]=(IndexPacket) pixel; |
|---|
| 270 | break; |
|---|
| 271 | } |
|---|
| 272 | } |
|---|
| 273 | q++; |
|---|
| 274 | } |
|---|
| 275 | if (SyncImagePixels(image) == MagickFalse) |
|---|
| 276 | break; |
|---|
| 277 | if ((image->columns % 2) != 0) |
|---|
| 278 | (void) ReadBlobByte(image); |
|---|
| 279 | } |
|---|
| 280 | status=SetImageProgress(image,LoadImageTag,y,image->rows); |
|---|
| 281 | if (status == MagickFalse) |
|---|
| 282 | break; |
|---|
| 283 | } |
|---|
| 284 | if (EOFBlob(image) != MagickFalse) |
|---|
| 285 | ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", |
|---|
| 286 | image->filename); |
|---|
| 287 | (void) CloseBlob(image); |
|---|
| 288 | return(GetFirstImageInList(image)); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | ModuleExport unsigned long RegisterSCTImage(void) |
|---|
| 315 | { |
|---|
| 316 | MagickInfo |
|---|
| 317 | *entry; |
|---|
| 318 | |
|---|
| 319 | entry=SetMagickInfo("SCT"); |
|---|
| 320 | entry->decoder=(DecodeImageHandler *) ReadSCTImage; |
|---|
| 321 | entry->magick=(IsImageFormatHandler *) IsSCT; |
|---|
| 322 | entry->adjoin=MagickFalse; |
|---|
| 323 | entry->description=ConstantString("Scitex HandShake"); |
|---|
| 324 | entry->module=ConstantString("SCT"); |
|---|
| 325 | (void) RegisterMagickInfo(entry); |
|---|
| 326 | return(MagickImageCoderSignature); |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | |
|---|
| 334 | |
|---|
| 335 | |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | |
|---|
| 343 | |
|---|
| 344 | |
|---|
| 345 | |
|---|
| 346 | |
|---|
| 347 | |
|---|
| 348 | ModuleExport void UnregisterSCTImage(void) |
|---|
| 349 | { |
|---|
| 350 | (void) UnregisterMagickInfo("SCT"); |
|---|
| 351 | } |
|---|