cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % X X TTTTT RRRR N N % |
| 7 | % X X T R R NN N % |
| 8 | % X T RRRR N N N % |
| 9 | % X X T R R N NN % |
| 10 | % X X T R R N N % |
| 11 | % % |
| 12 | % % |
| 13 | % ImageMagickObject BLOB Interface. % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % William Radcliffe % |
| 17 | % May 2001 % |
| 18 | % % |
| 19 | % % |
| 20 | % Copyright 1999-2007 ImageMagick Studio LLC, a non-profit organization % |
| 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | % % |
| 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 36 | % |
| 37 | % This coder is a kind of backdoor used by the COM object that allows it to % |
| 38 | % pass blobs back and forth using the coder interface. It simply encodes and % |
| 39 | % decodes the filename as a comma delimited string and extracts the info it % |
| 40 | % needs. The five methods of passing images are: % |
| 41 | % % |
| 42 | % FILE - same thing as filename so it should be a NOP % |
| 43 | % IMAGE - passes an image and image info structure % |
| 44 | % BLOB - passes binary blob containining the image % |
| 45 | % STREAM - passes pointers to stream hooks in and does the hooking % |
| 46 | % ARRAY - passes a pointer to a Win32 smart array and streams to it % |
| 47 | % % |
| 48 | % Of all of these, the only one getting any real use at the moment is the % |
| 49 | % ARRAY handler. It is the primary way that images are shuttled back and % |
| 50 | % forth as blobs via COM since this is what VB and VBSCRIPT use internally % |
| 51 | % for this purpose. % |
| 52 | % |
| 53 | % |
| 54 | */ |
| 55 | |
| 56 | /* |
| 57 | Include declarations. |
| 58 | */ |
| 59 | #if defined(_VISUALC_) |
| 60 | #include "magick/studio.h" |
| 61 | #include "magick/blob.h" |
| 62 | #include "magick/blob-private.h" |
| 63 | #include "magick/constitute.h" |
| 64 | #include "magick/delegate.h" |
| 65 | #include "magick/exception.h" |
| 66 | #include "magick/exception-private.h" |
| 67 | #include "magick/image.h" |
| 68 | #include "magick/image-private.h" |
| 69 | #include "magick/list.h" |
| 70 | #include "magick/magick.h" |
| 71 | #include "magick/memory_.h" |
| 72 | #include "magick/string_.h" |
| 73 | #define WIN32_LEAN_AND_MEAN |
| 74 | #define VC_EXTRALEAN |
| 75 | #include <windows.h> |
| 76 | #include <ole2.h> |
| 77 | |
| 78 | /* |
| 79 | Forward declarations. |
| 80 | */ |
| 81 | static MagickBooleanType |
| 82 | WriteXTRNImage(const ImageInfo *,Image *); |
| 83 | |
| 84 | /* |
| 85 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 86 | % % |
| 87 | % % |
| 88 | % % |
| 89 | % R e a d X T R N I m a g e % |
| 90 | % % |
| 91 | % % |
| 92 | % % |
| 93 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 94 | % |
| 95 | % ReadXTRNImage() reads a XTRN image file and returns it. It |
| 96 | % allocates the memory necessary for the new Image structure and returns a |
| 97 | % pointer to the new image. |
| 98 | % |
| 99 | % The format of the ReadXTRNImage method is: |
| 100 | % |
| 101 | % Image *ReadXTRNImage(const ImageInfo *image_info, |
| 102 | % ExceptionInfo *exception) |
| 103 | % |
| 104 | % A description of each parameter follows: |
| 105 | % |
| 106 | % o image_info: Specifies a pointer to an ImageInfo structure. |
| 107 | % |
| 108 | % o exception: return any errors or warnings in this structure. |
| 109 | % |
| 110 | */ |
| 111 | static Image *ReadXTRNImage(const ImageInfo *image_info, |
| 112 | ExceptionInfo *exception) |
| 113 | { |
| 114 | Image |
| 115 | *image; |
| 116 | |
| 117 | ImageInfo |
| 118 | *clone_info; |
| 119 | |
| 120 | void |
| 121 | *param1, |
| 122 | *param2, |
| 123 | *param3; |
| 124 | |
| 125 | param1 = param2 = param3 = (void *) NULL; |
| 126 | image = (Image *) NULL; |
| 127 | clone_info=CloneImageInfo(image_info); |
| 128 | if (clone_info->filename == NULL) |
| 129 | { |
| 130 | clone_info=DestroyImageInfo(clone_info); |
| 131 | ThrowReaderException(FileOpenWarning,"No filename specified"); |
| 132 | } |
| 133 | if (LocaleCompare(image_info->magick,"XTRNFILE") == 0) |
| 134 | { |
| 135 | image=ReadImage(clone_info,exception); |
| 136 | CatchException(exception); |
| 137 | } |
| 138 | else if (LocaleCompare(image_info->magick,"XTRNIMAGE") == 0) |
| 139 | { |
| 140 | Image |
| 141 | **image_ptr; |
| 142 | |
| 143 | #ifdef ALL_IMAGEINFO |
| 144 | ImageInfo |
| 145 | **image_info_ptr; |
| 146 | #endif |
| 147 | |
| 148 | (void) sscanf(clone_info->filename,"%lx,%lx",¶m1,¶m2); |
| 149 | image_ptr=(Image **) param2; |
| 150 | if (*image_ptr != (Image *)NULL) |
| 151 | image=CloneImage(*image_ptr,0,0,MagickFalse,&(*image_ptr)->exception); |
| 152 | #ifdef ALL_IMAGEINFO |
| 153 | image_info_ptr=(ImageInfo **) param1; |
| 154 | if (*image_info_ptr != (ImageInfo *)NULL) |
| 155 | image_info=*image_info_ptr; |
| 156 | #endif |
| 157 | } |
| 158 | else if (LocaleCompare(image_info->magick,"XTRNBLOB") == 0) |
| 159 | { |
| 160 | char |
| 161 | **blob_data; |
| 162 | |
| 163 | size_t |
| 164 | *blob_length; |
| 165 | |
| 166 | char |
| 167 | filename[MaxTextExtent]; |
| 168 | |
| 169 | (void) sscanf(clone_info->filename,"%lx,%lx,%s",¶m1,¶m2,&filename); |
| 170 | blob_data=(char **) param1; |
| 171 | blob_length=(size_t *) param2; |
| 172 | image=BlobToImage(clone_info,*blob_data,*blob_length,exception); |
| 173 | CatchException(exception); |
| 174 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 175 | else if (LocaleCompare(image_info->magick,"XTRNARRAY") == 0) |
| 176 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 177 | char |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 178 | *blob_data, |
| 179 | filename[MaxTextExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 180 | |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 181 | HRESULT |
| 182 | hr; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 183 | |
cristy | 32f6912 | 2011-04-22 02:26:00 +0000 | [diff] [blame] | 184 | long |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 185 | lBoundl, |
| 186 | lBoundu; |
| 187 | |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 188 | SAFEARRAY |
| 189 | *pSafeArray; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 190 | |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 191 | size_t |
| 192 | blob_length; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 193 | |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 194 | *filename='\0'; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 195 | (void) sscanf(clone_info->filename,"%lx,%s",¶m1,&filename); |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 196 | hr=S_OK; |
| 197 | pSafeArray=(SAFEARRAY *) param1; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 198 | if (pSafeArray) |
| 199 | { |
cristy | 4231d78 | 2011-04-22 02:18:34 +0000 | [diff] [blame] | 200 | hr = SafeArrayGetLBound(pSafeArray, 1, &lBoundl); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 201 | if (SUCCEEDED(hr)) |
cristy | 4231d78 | 2011-04-22 02:18:34 +0000 | [diff] [blame] | 202 | hr = SafeArrayGetUBound(pSafeArray, 1, &lBoundu); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 203 | if (SUCCEEDED(hr)) |
| 204 | { |
cristy | 4231d78 | 2011-04-22 02:18:34 +0000 | [diff] [blame] | 205 | blob_length = lBoundu - lBoundl + 1; |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 206 | hr = SafeArrayAccessData(pSafeArray,(void**) &blob_data); |
cristy | 4231d78 | 2011-04-22 02:18:34 +0000 | [diff] [blame] | 207 | if(SUCCEEDED(hr)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 208 | { |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 209 | *clone_info->filename='\0'; |
| 210 | *clone_info->magick='\0'; |
cristy | 4231d78 | 2011-04-22 02:18:34 +0000 | [diff] [blame] | 211 | if (*filename != '\0') |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 212 | (void) CopyMagickString(clone_info->filename,filename, |
| 213 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 214 | image=BlobToImage(clone_info,blob_data,blob_length,exception); |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 215 | hr=SafeArrayUnaccessData(pSafeArray); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 216 | CatchException(exception); |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 221 | clone_info=DestroyImageInfo(clone_info); |
| 222 | return(image); |
| 223 | } |
| 224 | |
| 225 | /* |
| 226 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 227 | % % |
| 228 | % % |
| 229 | % % |
| 230 | % R e g i s t e r X T R N I m a g e % |
| 231 | % % |
| 232 | % % |
| 233 | % % |
| 234 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 235 | % |
| 236 | % RegisterXTRNImage() adds attributes for the XTRN image format to |
| 237 | % the list of supported formats. The attributes include the image format |
| 238 | % tag, a method to read and/or write the format, whether the format |
| 239 | % supports the saving of more than one frame to the same file or blob, |
| 240 | % whether the format supports native in-memory I/O, and a brief |
| 241 | % description of the format. |
| 242 | % |
| 243 | % The format of the RegisterXTRNImage method is: |
| 244 | % |
| 245 | % RegisterXTRNImage(void) |
| 246 | % |
| 247 | */ |
| 248 | ModuleExport void RegisterXTRNImage(void) |
| 249 | { |
| 250 | MagickInfo |
| 251 | *entry; |
| 252 | |
| 253 | entry=SetMagickInfo("XTRNFILE"); |
| 254 | entry->decoder=ReadXTRNImage; |
| 255 | entry->encoder=WriteXTRNImage; |
| 256 | entry->adjoin=MagickFalse; |
| 257 | entry->stealth=MagickTrue; |
| 258 | entry->description=ConstantString("External transfer of a file"); |
| 259 | entry->module=ConstantString("XTRN"); |
| 260 | RegisterMagickInfo(entry); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 261 | entry=SetMagickInfo("XTRNIMAGE"); |
| 262 | entry->decoder=ReadXTRNImage; |
| 263 | entry->encoder=WriteXTRNImage; |
| 264 | entry->adjoin=MagickFalse; |
| 265 | entry->stealth=MagickTrue; |
| 266 | entry->description=ConstantString("External transfer of a image in memory"); |
| 267 | entry->module=ConstantString("XTRN"); |
| 268 | RegisterMagickInfo(entry); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 269 | entry=SetMagickInfo("XTRNBLOB"); |
| 270 | entry->decoder=ReadXTRNImage; |
| 271 | entry->encoder=WriteXTRNImage; |
| 272 | entry->adjoin=MagickFalse; |
| 273 | entry->stealth=MagickTrue; |
| 274 | entry->description=ConstantString("IExternal transfer of a blob in memory"); |
| 275 | entry->module=ConstantString("XTRN"); |
| 276 | RegisterMagickInfo(entry); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 277 | entry=SetMagickInfo("XTRNARRAY"); |
| 278 | entry->decoder=ReadXTRNImage; |
| 279 | entry->encoder=WriteXTRNImage; |
| 280 | entry->adjoin=MagickFalse; |
| 281 | entry->stealth=MagickTrue; |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 282 | entry->description=ConstantString( |
| 283 | "External transfer via a smart array interface"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 284 | entry->module=ConstantString("XTRN"); |
| 285 | RegisterMagickInfo(entry); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | /* |
| 289 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 290 | % % |
| 291 | % % |
| 292 | % % |
| 293 | % U n r e g i s t e r X T R N I m a g e % |
| 294 | % % |
| 295 | % % |
| 296 | % % |
| 297 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 298 | % |
| 299 | % UnregisterXTRNImage() removes format registrations made by the |
| 300 | % XTRN module from the list of supported formats. |
| 301 | % |
| 302 | % The format of the UnregisterXTRNImage method is: |
| 303 | % |
| 304 | % UnregisterXTRNImage(void) |
| 305 | % |
| 306 | */ |
| 307 | ModuleExport void UnregisterXTRNImage(void) |
| 308 | { |
| 309 | UnregisterMagickInfo("XTRNFILE"); |
| 310 | UnregisterMagickInfo("XTRNIMAGE"); |
| 311 | UnregisterMagickInfo("XTRNBLOB"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 312 | UnregisterMagickInfo("XTRNARRAY"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /* |
| 316 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 317 | % % |
| 318 | % % |
| 319 | % % |
| 320 | % W r i t e X T R N I m a g e % |
| 321 | % % |
| 322 | % % |
| 323 | % % |
| 324 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 325 | % |
| 326 | % WriteXTRNImage() writes an image in the XTRN encoded image format. |
| 327 | % We use GIF because it is the only format that is compressed without |
| 328 | % requiring addition optional delegates (TIFF, ZIP, etc). |
| 329 | % |
| 330 | % The format of the WriteXTRNImage method is: |
| 331 | % |
| 332 | % MagickBooleanType WriteXTRNImage(const ImageInfo *image_info,Image *image) |
| 333 | % |
| 334 | % A description of each parameter follows. |
| 335 | % |
| 336 | % o image_info: Specifies a pointer to an ImageInfo structure. |
| 337 | % |
| 338 | % o image: A pointer to a Image structure. |
| 339 | % |
| 340 | % |
| 341 | */ |
| 342 | |
| 343 | size_t SafeArrayFifo(const Image *image,const void *data,const size_t length) |
| 344 | { |
| 345 | SAFEARRAYBOUND NewArrayBounds[1]; /* 1 Dimension */ |
| 346 | size_t tlen=length; |
| 347 | SAFEARRAY *pSafeArray = (SAFEARRAY *)image->client_data; |
| 348 | if (pSafeArray != NULL) |
| 349 | { |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 350 | long lBoundl, lBoundu, lCount; |
| 351 | HRESULT hr = S_OK; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 352 | /* First see how big the buffer currently is */ |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 353 | hr = SafeArrayGetLBound(pSafeArray, 1, &lBoundl); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 354 | if (FAILED(hr)) |
| 355 | return MagickFalse; |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 356 | hr = SafeArrayGetUBound(pSafeArray, 1, &lBoundu); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 357 | if (FAILED(hr)) |
| 358 | return MagickFalse; |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 359 | lCount = lBoundu - lBoundl + 1; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 360 | |
| 361 | if (length>0) |
| 362 | { |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 363 | unsigned char *pReturnBuffer = NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 364 | NewArrayBounds[0].lLbound = 0; /* Start-Index 0 */ |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 365 | NewArrayBounds[0].cElements = (unsigned long) (length+lCount); /* # Elemente */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 366 | hr = SafeArrayRedim(pSafeArray, NewArrayBounds); |
| 367 | if (FAILED(hr)) |
| 368 | return 0; |
| 369 | hr = SafeArrayAccessData(pSafeArray, (void**)&pReturnBuffer); |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 370 | if( FAILED(hr) ) |
| 371 | return 0; |
cristy | d05120d | 2011-04-22 13:00:41 +0000 | [diff] [blame] | 372 | (void) memcpy(pReturnBuffer+lCount,(unsigned char *) data,length); |
| 373 | hr=SafeArrayUnaccessData(pSafeArray); |
| 374 | if(FAILED(hr)) |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 375 | return 0; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 376 | } |
| 377 | else |
| 378 | { |
| 379 | /* Adjust the length of the buffer to fit */ |
| 380 | } |
cristy | ddbc41b | 2011-04-24 14:27:48 +0000 | [diff] [blame] | 381 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 382 | return(tlen); |
| 383 | } |
| 384 | |
| 385 | static MagickBooleanType WriteXTRNImage(const ImageInfo *image_info,Image *image) |
| 386 | { |
| 387 | Image * |
| 388 | p; |
| 389 | |
| 390 | ImageInfo |
| 391 | *clone_info; |
| 392 | |
| 393 | int |
| 394 | scene; |
| 395 | |
| 396 | MagickBooleanType |
| 397 | status; |
| 398 | |
| 399 | void |
| 400 | *param1, |
| 401 | *param2, |
| 402 | *param3; |
| 403 | |
| 404 | param1 = param2 = param3 = (void *) NULL; |
| 405 | if (LocaleCompare(image_info->magick,"XTRNFILE") == 0) |
| 406 | { |
| 407 | clone_info=CloneImageInfo(image_info); |
| 408 | status=WriteImage(image_info,image); |
| 409 | if (status == MagickFalse) |
| 410 | CatchImageException(image); |
| 411 | clone_info=DestroyImageInfo(clone_info); |
| 412 | } |
| 413 | else if (LocaleCompare(image_info->magick,"XTRNIMAGE") == 0) |
| 414 | { |
| 415 | Image |
| 416 | **image_ptr; |
| 417 | |
| 418 | ImageInfo |
| 419 | **image_info_ptr; |
| 420 | |
| 421 | clone_info=CloneImageInfo(image_info); |
| 422 | if (clone_info->filename[0]) |
| 423 | { |
| 424 | (void) sscanf(clone_info->filename,"%lx,%lx",¶m1,¶m2); |
| 425 | image_info_ptr=(ImageInfo **) param1; |
| 426 | image_ptr=(Image **) param2; |
| 427 | if ((image_info_ptr != (ImageInfo **) NULL) && |
| 428 | (image_ptr != (Image **) NULL)) |
| 429 | { |
| 430 | *image_ptr=CloneImage(image,0,0,MagickFalse,&(image->exception)); |
| 431 | *image_info_ptr=clone_info; |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | else if (LocaleCompare(image_info->magick,"XTRNBLOB") == 0) |
| 436 | { |
| 437 | char |
| 438 | **blob_data; |
| 439 | |
| 440 | ExceptionInfo |
| 441 | exception; |
| 442 | |
| 443 | size_t |
| 444 | *blob_length; |
| 445 | |
| 446 | char |
| 447 | filename[MaxTextExtent]; |
| 448 | |
| 449 | clone_info=CloneImageInfo(image_info); |
| 450 | if (clone_info->filename[0]) |
| 451 | { |
| 452 | (void) sscanf(clone_info->filename,"%lx,%lx,%s", |
| 453 | ¶m1,¶m2,&filename); |
| 454 | |
| 455 | blob_data=(char **) param1; |
| 456 | blob_length=(size_t *) param2; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 457 | scene = 0; |
| 458 | (void) CopyMagickString(clone_info->filename,filename,MaxTextExtent); |
| 459 | for (p=image; p != (Image *) NULL; p=GetNextImageInList(p)) |
| 460 | { |
| 461 | (void) CopyMagickString(p->filename,filename,MaxTextExtent); |
| 462 | p->scene=scene++; |
| 463 | } |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 464 | SetImageInfo(clone_info,1,&image->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 465 | (void) CopyMagickString(image->magick,clone_info->magick, |
| 466 | MaxTextExtent); |
| 467 | GetExceptionInfo(&exception); |
| 468 | if (*blob_length == 0) |
| 469 | *blob_length=8192; |
| 470 | *blob_data=(char *) ImageToBlob(clone_info,image,blob_length, |
| 471 | &exception); |
| 472 | if (*blob_data == NULL) |
| 473 | status=MagickFalse; |
| 474 | if (status == MagickFalse) |
| 475 | CatchImageException(image); |
| 476 | } |
| 477 | clone_info=DestroyImageInfo(clone_info); |
| 478 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 479 | else if (LocaleCompare(image_info->magick,"XTRNARRAY") == 0) |
| 480 | { |
| 481 | char |
| 482 | filename[MaxTextExtent]; |
| 483 | |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 484 | size_t |
cristy | 1652a65 | 2011-04-24 14:34:50 +0000 | [diff] [blame] | 485 | blob_length; |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 486 | |
| 487 | unsigned char |
| 488 | *blob_data; |
| 489 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 490 | clone_info=CloneImageInfo(image_info); |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 491 | if (*clone_info->filename != '\0') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 492 | { |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 493 | (void) sscanf(clone_info->filename,"%lx,%s",¶m1,&filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 494 | image->client_data=param1; |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 495 | scene=0; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 496 | (void) CopyMagickString(clone_info->filename,filename,MaxTextExtent); |
| 497 | for (p=image; p != (Image *) NULL; p=GetNextImageInList(p)) |
| 498 | { |
| 499 | (void) CopyMagickString(p->filename,filename,MaxTextExtent); |
| 500 | p->scene=scene++; |
| 501 | } |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 502 | SetImageInfo(clone_info,1,&image->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 503 | (void) CopyMagickString(image->magick,clone_info->magick, |
| 504 | MaxTextExtent); |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 505 | blob_data=ImageToBlob(clone_info,image,&blob_length, |
| 506 | &image->exception); |
| 507 | if (blob_data == (unsigned char *) NULL) |
cristy | 1652a65 | 2011-04-24 14:34:50 +0000 | [diff] [blame] | 508 | status=MagickFalse; |
cristy | df354f9 | 2011-04-22 02:40:55 +0000 | [diff] [blame] | 509 | else |
| 510 | SafeArrayFifo(image,blob_data,blob_length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 511 | if (status == MagickFalse) |
| 512 | CatchImageException(image); |
| 513 | } |
| 514 | clone_info=DestroyImageInfo(clone_info); |
| 515 | } |
| 516 | return(MagickTrue); |
| 517 | } |
| 518 | #endif |