blob: 8e88534b0429cadd1f53b22a50e37674d852f0c3 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% CCCC AAA L SSSSS %
7% C A A L SS %
8% C AAAAA L SSS %
9% C A A L SS %
10% CCCC A A LLLLL SSSSS %
11% %
12% %
cristy47b838c2009-09-19 16:09:30 +000013% Read/Write CALS Raster Group 1 Image Format %
cristy3ed852e2009-09-05 21:47:34 +000014% %
15% Software Design %
16% John Cristy %
17% July 1992 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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% The CALS raster format is a standard developed by the Computer Aided
37% Acquisition and Logistics Support (CALS) office of the United States
38% Department of Defense to standardize graphics data interchange for
39% electronic publishing, especially in the areas of technical graphics,
40% CAD/CAM, and image processing applications.
41%
42*/
43
44/*
45 Include declarations.
46*/
cristy4c08aed2011-07-01 19:47:50 +000047#include "MagickCore/studio.h"
48#include "MagickCore/blob.h"
49#include "MagickCore/blob-private.h"
50#include "MagickCore/cache.h"
51#include "MagickCore/colorspace.h"
52#include "MagickCore/exception.h"
53#include "MagickCore/exception-private.h"
54#include "MagickCore/geometry.h"
55#include "MagickCore/image.h"
56#include "MagickCore/image-private.h"
57#include "MagickCore/list.h"
58#include "MagickCore/magick.h"
59#include "MagickCore/memory_.h"
60#include "MagickCore/monitor.h"
61#include "MagickCore/monitor-private.h"
62#include "MagickCore/option.h"
63#include "MagickCore/quantum-private.h"
64#include "MagickCore/resource_.h"
65#include "MagickCore/static.h"
66#include "MagickCore/string_.h"
67#include "MagickCore/module.h"
cristy3ed852e2009-09-05 21:47:34 +000068
cristy20a78b22010-04-05 01:22:12 +000069#if defined(MAGICKCORE_TIFF_DELEGATE)
cristy3ed852e2009-09-05 21:47:34 +000070/*
cristy03117002009-09-19 02:10:44 +000071 Forward declarations.
72*/
73static MagickBooleanType
74 WriteCALSImage(const ImageInfo *,Image *);
cristy20a78b22010-04-05 01:22:12 +000075#endif
cristy03117002009-09-19 02:10:44 +000076
77/*
cristy3ed852e2009-09-05 21:47:34 +000078%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79% %
80% %
81% %
82% I s C A L S %
83% %
84% %
85% %
86%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87%
88% IsCALS() returns MagickTrue if the image format type, identified by the
cristy47b838c2009-09-19 16:09:30 +000089% magick string, is CALS Raster Group 1.
cristy3ed852e2009-09-05 21:47:34 +000090%
91% The format of the IsCALS method is:
92%
93% MagickBooleanType IsCALS(const unsigned char *magick,const size_t length)
94%
95% A description of each parameter follows:
96%
97% o magick: compare image format pattern against these bytes.
98%
99% o length: Specifies the length of the magick string.
100%
101*/
102static MagickBooleanType IsCALS(const unsigned char *magick,const size_t length)
103{
104 if (length < 128)
105 return(MagickFalse);
cristy03117002009-09-19 02:10:44 +0000106 if (LocaleNCompare((const char *) magick,"version: MIL-STD-1840",21) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000107 return(MagickTrue);
cristy03117002009-09-19 02:10:44 +0000108 if (LocaleNCompare((const char *) magick,"srcdocid:",9) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000109 return(MagickTrue);
cristy03117002009-09-19 02:10:44 +0000110 if (LocaleNCompare((const char *) magick,"rorient:",8) == 0)
cristy3ed852e2009-09-05 21:47:34 +0000111 return(MagickTrue);
112 return(MagickFalse);
113}
114
115/*
116%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117% %
118% %
119% %
120% R e a d C A L S I m a g e %
121% %
122% %
123% %
124%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125%
cristy47b838c2009-09-19 16:09:30 +0000126% ReadCALSImage() reads an CALS Raster Group 1 image format image file and
127% returns it. It allocates the memory necessary for the new Image structure
128% and returns a pointer to the new image.
cristy3ed852e2009-09-05 21:47:34 +0000129%
130% The format of the ReadCALSImage method is:
131%
132% Image *ReadCALSImage(const ImageInfo *image_info,
133% ExceptionInfo *exception)
134%
135% A description of each parameter follows:
136%
137% o image_info: the image info.
138%
139% o exception: return any errors or warnings in this structure.
140%
141*/
cristy2d6ccc32009-09-25 03:18:25 +0000142static Image *ReadCALSImage(const ImageInfo *image_info,
cristy3ed852e2009-09-05 21:47:34 +0000143 ExceptionInfo *exception)
144{
145 char
cristy2d6ccc32009-09-25 03:18:25 +0000146 filename[MaxTextExtent],
147 header[129],
148 message[MaxTextExtent];
cristy3ed852e2009-09-05 21:47:34 +0000149
150 FILE
151 *file;
152
153 Image
cristy2d6ccc32009-09-25 03:18:25 +0000154 *image;
cristy3ed852e2009-09-05 21:47:34 +0000155
156 ImageInfo
157 *read_info;
158
159 int
160 c,
161 unique_file;
162
cristy47b838c2009-09-19 16:09:30 +0000163 MagickBooleanType
164 status;
165
cristybb503372010-05-27 20:51:26 +0000166 register ssize_t
cristy47b838c2009-09-19 16:09:30 +0000167 i;
168
cristyb5af3b02011-04-24 03:01:28 +0000169 unsigned long
cristy3ed852e2009-09-05 21:47:34 +0000170 density,
171 direction,
172 height,
173 orientation,
174 pel_path,
175 type,
176 width;
177
178 /*
179 Open image file.
180 */
181 assert(image_info != (const ImageInfo *) NULL);
182 assert(image_info->signature == MagickSignature);
183 if (image_info->debug != MagickFalse)
184 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
185 image_info->filename);
186 assert(exception != (ExceptionInfo *) NULL);
187 assert(exception->signature == MagickSignature);
188 image=AcquireImage(image_info);
189 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
190 if (status == MagickFalse)
191 {
192 image=DestroyImageList(image);
193 return((Image *) NULL);
194 }
195 /*
196 Read CALS header.
197 */
198 (void) ResetMagickMemory(header,0,sizeof(header));
199 density=0;
200 direction=0;
201 orientation=1;
202 pel_path=0;
203 type=1;
204 width=0;
205 height=0;
206 for (i=0; i < 16; i++)
207 {
208 if (ReadBlob(image,128,(unsigned char *) header) != 128)
209 break;
210 switch (*header)
211 {
212 case 'R':
213 case 'r':
214 {
215 if (LocaleNCompare(header,"rdensty:",8) == 0)
216 {
cristy47b838c2009-09-19 16:09:30 +0000217 (void) sscanf(header+8,"%lu",&density);
cristy3ed852e2009-09-05 21:47:34 +0000218 break;
219 }
220 if (LocaleNCompare(header,"rpelcnt:",8) == 0)
221 {
cristy47b838c2009-09-19 16:09:30 +0000222 (void) sscanf(header+8,"%lu,%lu",&width,&height);
cristy3ed852e2009-09-05 21:47:34 +0000223 break;
224 }
225 if (LocaleNCompare(header,"rorient:",8) == 0)
226 {
cristy47b838c2009-09-19 16:09:30 +0000227 (void) sscanf(header+8,"%lu,%lu",&pel_path,&direction);
cristy3ed852e2009-09-05 21:47:34 +0000228 if (pel_path == 90)
229 orientation=5;
230 else
cristy2e68c0c2010-04-06 13:10:46 +0000231 if (pel_path == 180)
cristy3ed852e2009-09-05 21:47:34 +0000232 orientation=3;
233 else
234 if (pel_path == 270)
235 orientation=7;
236 if (direction == 90)
237 orientation++;
238 break;
239 }
240 if (LocaleNCompare(header,"rtype:",6) == 0)
241 {
cristy47b838c2009-09-19 16:09:30 +0000242 (void) sscanf(header+6,"%lu",&type);
cristy3ed852e2009-09-05 21:47:34 +0000243 break;
244 }
245 break;
246 }
247 }
248 }
cristy2d6ccc32009-09-25 03:18:25 +0000249 /*
250 Read CALS pixels.
251 */
252 file=(FILE *) NULL;
253 unique_file=AcquireUniqueFileResource(filename);
254 if (unique_file != -1)
255 file=fdopen(unique_file,"wb");
256 if ((unique_file == -1) || (file == (FILE *) NULL))
257 ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile");
258 while ((c=ReadBlobByte(image)) != EOF)
259 (void) fputc(c,file);
260 (void) fclose(file);
261 (void) CloseBlob(image);
cristy3ed852e2009-09-05 21:47:34 +0000262 image=DestroyImage(image);
cristy2d6ccc32009-09-25 03:18:25 +0000263 read_info=CloneImageInfo(image_info);
264 SetImageInfoBlob(read_info,(void *) NULL,0);
cristyb51dff52011-05-19 16:55:47 +0000265 (void) FormatLocaleString(read_info->filename,MaxTextExtent,"group4:%s",
cristy2d6ccc32009-09-25 03:18:25 +0000266 filename);
cristyb51dff52011-05-19 16:55:47 +0000267 (void) FormatLocaleString(message,MaxTextExtent,"%lux%lu",width,height);
cristy2d6ccc32009-09-25 03:18:25 +0000268 read_info->size=ConstantString(message);
cristyb51dff52011-05-19 16:55:47 +0000269 (void) FormatLocaleString(message,MaxTextExtent,"%lu",density);
cristy2d6ccc32009-09-25 03:18:25 +0000270 read_info->density=ConstantString(message);
271 read_info->orientation=(OrientationType) orientation;
272 image=ReadImage(read_info,exception);
273 if (image != (Image *) NULL)
274 {
275 (void) CopyMagickString(image->filename,image_info->filename,
276 MaxTextExtent);
277 (void) CopyMagickString(image->magick_filename,image_info->filename,
278 MaxTextExtent);
279 (void) CopyMagickString(image->magick,"CALS",MaxTextExtent);
280 }
281 read_info=DestroyImageInfo(read_info);
282 (void) RelinquishUniqueFileResource(filename);
283 return(image);
cristy3ed852e2009-09-05 21:47:34 +0000284}
285
286/*
287%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288% %
289% %
290% %
291% R e g i s t e r C A L S I m a g e %
292% %
293% %
294% %
295%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
296%
cristy47b838c2009-09-19 16:09:30 +0000297% RegisterCALSImage() adds attributes for the CALS Raster Group 1 image file
298% image format to the list of supported formats. The attributes include the
299% image format tag, a method to read and/or write the format, whether the
300% format supports the saving of more than one frame to the same file or blob,
301% whether the format supports native in-memory I/O, and a brief description
302% of the format.
cristy3ed852e2009-09-05 21:47:34 +0000303%
304% The format of the RegisterCALSImage method is:
305%
cristybb503372010-05-27 20:51:26 +0000306% size_t RegisterCALSImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000307%
308*/
cristybb503372010-05-27 20:51:26 +0000309ModuleExport size_t RegisterCALSImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000310{
311 MagickInfo
312 *entry;
313
cristy9ca59552009-09-23 13:40:25 +0000314 static const char
315 *CALSDescription=
316 {
cristyc4a5dd22010-01-02 02:41:21 +0000317 "Continuous Acquisition and Life-cycle Support Type 1"
cristy9ca59552009-09-23 13:40:25 +0000318 },
319 *CALSNote=
320 {
321 "Specified in MIL-R-28002 and MIL-PRF-28002"
322 };
323
324 entry=SetMagickInfo("CAL");
cristy3ed852e2009-09-05 21:47:34 +0000325 entry->decoder=(DecodeImageHandler *) ReadCALSImage;
cristy9ca59552009-09-23 13:40:25 +0000326#if defined(MAGICKCORE_TIFF_DELEGATE)
cristy03117002009-09-19 02:10:44 +0000327 entry->encoder=(EncodeImageHandler *) WriteCALSImage;
cristy9ca59552009-09-23 13:40:25 +0000328#endif
cristy3ed852e2009-09-05 21:47:34 +0000329 entry->adjoin=MagickFalse;
330 entry->magick=(IsImageFormatHandler *) IsCALS;
cristy9ca59552009-09-23 13:40:25 +0000331 entry->description=ConstantString(CALSDescription);
332 entry->note=ConstantString(CALSNote);
333 entry->module=ConstantString("CALS");
334 (void) RegisterMagickInfo(entry);
335 entry=SetMagickInfo("CALS");
336 entry->decoder=(DecodeImageHandler *) ReadCALSImage;
337#if defined(MAGICKCORE_TIFF_DELEGATE)
338 entry->encoder=(EncodeImageHandler *) WriteCALSImage;
339#endif
340 entry->adjoin=MagickFalse;
341 entry->magick=(IsImageFormatHandler *) IsCALS;
342 entry->description=ConstantString(CALSDescription);
343 entry->note=ConstantString(CALSNote);
cristy3ed852e2009-09-05 21:47:34 +0000344 entry->module=ConstantString("CALS");
345 (void) RegisterMagickInfo(entry);
346 return(MagickImageCoderSignature);
347}
348
349/*
350%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351% %
352% %
353% %
354% U n r e g i s t e r C A L S I m a g e %
355% %
356% %
357% %
358%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
359%
360% UnregisterCALSImage() removes format registrations made by the
361% CALS module from the list of supported formats.
362%
363% The format of the UnregisterCALSImage method is:
364%
365% UnregisterCALSImage(void)
366%
367*/
368ModuleExport void UnregisterCALSImage(void)
369{
cristy9ca59552009-09-23 13:40:25 +0000370 (void) UnregisterMagickInfo("CAL");
cristy3ed852e2009-09-05 21:47:34 +0000371 (void) UnregisterMagickInfo("CALS");
372}
cristy03117002009-09-19 02:10:44 +0000373
cristy316dac12009-12-07 17:19:28 +0000374#if defined(MAGICKCORE_TIFF_DELEGATE)
cristy03117002009-09-19 02:10:44 +0000375/*
376%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377% %
378% %
379% %
380% W r i t e C A L S I m a g e %
381% %
382% %
383% %
384%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
385%
cristy47b838c2009-09-19 16:09:30 +0000386% WriteCALSImage() writes an image to a file in CALS Raster Group 1 image
387% format.
cristy03117002009-09-19 02:10:44 +0000388%
389% The format of the WriteCALSImage method is:
390%
391% MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
392% Image *image)
393%
394% A description of each parameter follows.
395%
396% o image_info: the image info.
397%
398% o image: The image.
399%
400*/
401
cristy47b838c2009-09-19 16:09:30 +0000402static ssize_t WriteCALSRecord(Image *image,const char *data)
cristy03117002009-09-19 02:10:44 +0000403{
404 char
405 pad[128];
406
cristy03117002009-09-19 02:10:44 +0000407 register const char
408 *p;
409
cristybb503372010-05-27 20:51:26 +0000410 register ssize_t
cristy03117002009-09-19 02:10:44 +0000411 i;
412
cristy4e82e512011-04-24 01:33:42 +0000413 ssize_t
414 count;
415
cristy03117002009-09-19 02:10:44 +0000416 i=0;
417 if (data != (const char *) NULL)
418 {
419 p=data;
420 for (i=0; (i < 128) && (p[i] != '\0'); i++);
cristy47b838c2009-09-19 16:09:30 +0000421 count=WriteBlob(image,(size_t) i,(const unsigned char *) data);
cristy03117002009-09-19 02:10:44 +0000422 }
423 if (i < 128)
424 {
cristy03117002009-09-19 02:10:44 +0000425 i=128-i;
cristy47b838c2009-09-19 16:09:30 +0000426 (void) ResetMagickMemory(pad,' ',(const size_t) i);
427 count=WriteBlob(image,(size_t) i,(const unsigned char *) pad);
cristy03117002009-09-19 02:10:44 +0000428 }
429 return(count);
430}
431
432static MagickBooleanType WriteCALSImage(const ImageInfo *image_info,
433 Image *image)
434{
435 char
cristy2d6ccc32009-09-25 03:18:25 +0000436 header[129];
437
438 Image
439 *group4_image;
440
441 ImageInfo
442 *write_info;
cristy03117002009-09-19 02:10:44 +0000443
444 MagickBooleanType
445 status;
446
cristybb503372010-05-27 20:51:26 +0000447 register ssize_t
cristy03117002009-09-19 02:10:44 +0000448 i;
449
cristy4e82e512011-04-24 01:33:42 +0000450 size_t
451 density,
452 length,
453 orient_x,
454 orient_y;
455
cristy03117002009-09-19 02:10:44 +0000456 ssize_t
457 count;
458
cristy2d6ccc32009-09-25 03:18:25 +0000459 unsigned char
460 *group4;
461
cristy03117002009-09-19 02:10:44 +0000462 /*
463 Open output image file.
464 */
465 assert(image_info != (const ImageInfo *) NULL);
466 assert(image_info->signature == MagickSignature);
467 assert(image != (Image *) NULL);
468 assert(image->signature == MagickSignature);
469 if (image->debug != MagickFalse)
470 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
471 status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
472 if (status == MagickFalse)
473 return(status);
474 /*
475 Create standard CALS header.
476 */
477 count=WriteCALSRecord(image,"srcdocid: NONE");
cristyda16f162011-02-19 23:52:17 +0000478 (void) count;
cristy03117002009-09-19 02:10:44 +0000479 count=WriteCALSRecord(image,"dstdocid: NONE");
480 count=WriteCALSRecord(image,"txtfilid: NONE");
481 count=WriteCALSRecord(image,"figid: NONE");
482 count=WriteCALSRecord(image,"srcgph: NONE");
483 count=WriteCALSRecord(image,"docls: NONE");
484 count=WriteCALSRecord(image,"rtype: 1");
cristy43b2de02009-09-19 16:19:31 +0000485 orient_x=0;
486 orient_y=0;
cristy03117002009-09-19 02:10:44 +0000487 switch (image->orientation)
488 {
489 case TopRightOrientation:
490 {
491 orient_x=180;
492 orient_y=270;
493 break;
494 }
495 case BottomRightOrientation:
496 {
497 orient_x=180;
498 orient_y=90;
499 break;
500 }
501 case BottomLeftOrientation:
cristy43b2de02009-09-19 16:19:31 +0000502 {
cristy03117002009-09-19 02:10:44 +0000503 orient_y=90;
504 break;
cristy43b2de02009-09-19 16:19:31 +0000505 }
cristy03117002009-09-19 02:10:44 +0000506 case LeftTopOrientation:
507 {
508 orient_x=270;
cristy03117002009-09-19 02:10:44 +0000509 break;
510 }
511 case RightTopOrientation:
512 {
513 orient_x=270;
514 orient_y=180;
515 break;
516 }
517 case RightBottomOrientation:
518 {
519 orient_x=90;
520 orient_y=180;
521 break;
522 }
523 case LeftBottomOrientation:
524 {
525 orient_x=90;
cristy03117002009-09-19 02:10:44 +0000526 break;
527 }
528 default:
529 {
cristy03117002009-09-19 02:10:44 +0000530 orient_y=270;
531 }
532 }
cristyb51dff52011-05-19 16:55:47 +0000533 (void) FormatLocaleString(header,MaxTextExtent,"rorient: %03ld,%03ld",
cristyf2faecf2010-05-28 19:19:36 +0000534 (long) orient_x,(long) orient_y);
cristy2d6ccc32009-09-25 03:18:25 +0000535 count=WriteCALSRecord(image,header);
cristyb51dff52011-05-19 16:55:47 +0000536 (void) FormatLocaleString(header,MaxTextExtent,"rpelcnt: %06lu,%06lu",
cristyf2faecf2010-05-28 19:19:36 +0000537 (unsigned long) image->columns,(unsigned long) image->rows);
cristy2d6ccc32009-09-25 03:18:25 +0000538 count=WriteCALSRecord(image,header);
cristy03117002009-09-19 02:10:44 +0000539 density=200;
540 if (image_info->density != (char *) NULL)
541 {
542 GeometryInfo
543 geometry_info;
544
545 (void) ParseGeometry(image_info->density,&geometry_info);
cristybb503372010-05-27 20:51:26 +0000546 density=(size_t) floor(geometry_info.rho+0.5);
cristy03117002009-09-19 02:10:44 +0000547 }
cristyb51dff52011-05-19 16:55:47 +0000548 (void) FormatLocaleString(header,MaxTextExtent,"rdensty: %04lu",
cristyf2faecf2010-05-28 19:19:36 +0000549 (unsigned long) density);
cristy2d6ccc32009-09-25 03:18:25 +0000550 count=WriteCALSRecord(image,header);
cristy03117002009-09-19 02:10:44 +0000551 count=WriteCALSRecord(image,"notes: NONE");
cristy2d6ccc32009-09-25 03:18:25 +0000552 (void) ResetMagickMemory(header,' ',128);
cristy03117002009-09-19 02:10:44 +0000553 for (i=0; i < 5; i++)
cristy2d6ccc32009-09-25 03:18:25 +0000554 (void) WriteBlob(image,128,(unsigned char *) header);
555 /*
556 Write CALS pixels.
557 */
558 write_info=CloneImageInfo(image_info);
559 (void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent);
560 (void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent);
561 group4_image=CloneImage(image,0,0,MagickTrue,&image->exception);
562 if (group4_image == (Image *) NULL)
563 {
564 (void) CloseBlob(image);
565 return(MagickFalse);
566 }
567 group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length,
568 &image->exception);
569 group4_image=DestroyImage(group4_image);
570 if (group4 == (unsigned char *) NULL)
571 {
572 (void) CloseBlob(image);
573 return(MagickFalse);
574 }
575 write_info=DestroyImageInfo(write_info);
576 if (WriteBlob(image,length,group4) != (ssize_t) length)
577 status=MagickFalse;
578 group4=(unsigned char *) RelinquishMagickMemory(group4);
cristy03117002009-09-19 02:10:44 +0000579 (void) CloseBlob(image);
580 return(status);
581}
cristy316dac12009-12-07 17:19:28 +0000582#endif