cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % TTTTT X X TTTTT % |
| 7 | % T X X T % |
| 8 | % T X T % |
| 9 | % T X X T % |
| 10 | % T X X T % |
| 11 | % % |
| 12 | % % |
| 13 | % Render Text Onto A Canvas Image. % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % July 1992 % |
| 18 | % % |
| 19 | % % |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | */ |
| 38 | |
| 39 | /* |
| 40 | Include declarations. |
| 41 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 42 | #include "MagickCore/studio.h" |
| 43 | #include "MagickCore/annotate.h" |
| 44 | #include "MagickCore/attribute.h" |
| 45 | #include "MagickCore/blob.h" |
| 46 | #include "MagickCore/blob-private.h" |
| 47 | #include "MagickCore/cache.h" |
| 48 | #include "MagickCore/color.h" |
| 49 | #include "MagickCore/color-private.h" |
| 50 | #include "MagickCore/colorspace.h" |
| 51 | #include "MagickCore/constitute.h" |
| 52 | #include "MagickCore/draw.h" |
| 53 | #include "MagickCore/exception.h" |
| 54 | #include "MagickCore/exception-private.h" |
| 55 | #include "MagickCore/geometry.h" |
| 56 | #include "MagickCore/image.h" |
| 57 | #include "MagickCore/image-private.h" |
| 58 | #include "MagickCore/list.h" |
| 59 | #include "MagickCore/magick.h" |
| 60 | #include "MagickCore/memory_.h" |
| 61 | #include "MagickCore/monitor.h" |
| 62 | #include "MagickCore/monitor-private.h" |
| 63 | #include "MagickCore/option.h" |
| 64 | #include "MagickCore/pixel-accessor.h" |
| 65 | #include "MagickCore/quantum-private.h" |
| 66 | #include "MagickCore/static.h" |
| 67 | #include "MagickCore/statistic.h" |
| 68 | #include "MagickCore/string_.h" |
| 69 | #include "MagickCore/module.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 70 | |
| 71 | /* |
| 72 | Forward declarations. |
| 73 | */ |
| 74 | static MagickBooleanType |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 75 | WriteTXTImage(const ImageInfo *,Image *,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 79 | % % |
| 80 | % % |
| 81 | % % |
| 82 | % I s T X T % |
| 83 | % % |
| 84 | % % |
| 85 | % % |
| 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 87 | % |
| 88 | % IsTXT() returns MagickTrue if the image format type, identified by the magick |
| 89 | % string, is TXT. |
| 90 | % |
| 91 | % The format of the IsTXT method is: |
| 92 | % |
| 93 | % MagickBooleanType IsTXT(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 | */ |
| 102 | static MagickBooleanType IsTXT(const unsigned char *magick,const size_t length) |
| 103 | { |
| 104 | #define MagickID "# ImageMagick pixel enumeration:" |
| 105 | |
| 106 | char |
| 107 | colorspace[MaxTextExtent]; |
| 108 | |
| 109 | ssize_t |
| 110 | count; |
| 111 | |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 112 | unsigned long |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 113 | columns, |
| 114 | depth, |
| 115 | rows; |
| 116 | |
| 117 | if (length < 40) |
| 118 | return(MagickFalse); |
| 119 | if (LocaleNCompare((const char *) magick,MagickID,strlen(MagickID)) != 0) |
| 120 | return(MagickFalse); |
| 121 | count=(ssize_t) sscanf((const char *) magick+32,"%lu,%lu,%lu,%s",&columns, |
| 122 | &rows,&depth,colorspace); |
| 123 | if (count != 4) |
| 124 | return(MagickFalse); |
| 125 | return(MagickTrue); |
| 126 | } |
| 127 | |
| 128 | /* |
| 129 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 130 | % % |
| 131 | % % |
| 132 | % % |
| 133 | % R e a d T E X T I m a g e % |
| 134 | % % |
| 135 | % % |
| 136 | % % |
| 137 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 138 | % |
| 139 | % ReadTEXTImage() reads a text file and returns it as an image. It |
| 140 | % allocates the memory necessary for the new Image structure and returns a |
| 141 | % pointer to the new image. |
| 142 | % |
| 143 | % The format of the ReadTEXTImage method is: |
| 144 | % |
| 145 | % Image *ReadTEXTImage(const ImageInfo *image_info,Image *image, |
| 146 | % char *text,ExceptionInfo *exception) |
| 147 | % |
| 148 | % A description of each parameter follows: |
| 149 | % |
| 150 | % o image_info: the image info. |
| 151 | % |
| 152 | % o image: the image. |
| 153 | % |
| 154 | % o text: the text storage buffer. |
| 155 | % |
| 156 | % o exception: return any errors or warnings in this structure. |
| 157 | % |
| 158 | */ |
| 159 | static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image, |
| 160 | char *text,ExceptionInfo *exception) |
| 161 | { |
| 162 | char |
| 163 | filename[MaxTextExtent], |
| 164 | geometry[MaxTextExtent], |
| 165 | *p; |
| 166 | |
| 167 | DrawInfo |
| 168 | *draw_info; |
| 169 | |
| 170 | Image |
| 171 | *texture; |
| 172 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 173 | MagickBooleanType |
| 174 | status; |
| 175 | |
| 176 | PointInfo |
| 177 | delta; |
| 178 | |
| 179 | RectangleInfo |
| 180 | page; |
| 181 | |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 182 | ssize_t |
| 183 | offset; |
| 184 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 185 | TypeMetric |
| 186 | metrics; |
| 187 | |
| 188 | /* |
| 189 | Open image file. |
| 190 | */ |
| 191 | assert(image_info != (const ImageInfo *) NULL); |
| 192 | assert(image_info->signature == MagickSignature); |
| 193 | if (image_info->debug != MagickFalse) |
| 194 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 195 | image_info->filename); |
| 196 | assert(exception != (ExceptionInfo *) NULL); |
| 197 | assert(exception->signature == MagickSignature); |
| 198 | /* |
| 199 | Set the page geometry. |
| 200 | */ |
| 201 | delta.x=DefaultResolution; |
| 202 | delta.y=DefaultResolution; |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 203 | if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 204 | { |
| 205 | GeometryInfo |
| 206 | geometry_info; |
| 207 | |
| 208 | MagickStatusType |
| 209 | flags; |
| 210 | |
| 211 | flags=ParseGeometry(PSDensityGeometry,&geometry_info); |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 212 | image->resolution.x=geometry_info.rho; |
| 213 | image->resolution.y=geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 214 | if ((flags & SigmaValue) == 0) |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 215 | image->resolution.y=image->resolution.x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 216 | } |
| 217 | page.width=612; |
| 218 | page.height=792; |
| 219 | page.x=43; |
| 220 | page.y=43; |
| 221 | if (image_info->page != (char *) NULL) |
| 222 | (void) ParseAbsoluteGeometry(image_info->page,&page); |
| 223 | /* |
| 224 | Initialize Image structure. |
| 225 | */ |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 226 | image->columns=(size_t) floor((((double) page.width*image->resolution.x)/ |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 227 | delta.x)+0.5); |
cristy | 2a11bef | 2011-10-28 18:33:11 +0000 | [diff] [blame] | 228 | image->rows=(size_t) floor((((double) page.height*image->resolution.y)/ |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 229 | delta.y)+0.5); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 230 | image->page.x=0; |
| 231 | image->page.y=0; |
| 232 | texture=(Image *) NULL; |
| 233 | if (image_info->texture != (char *) NULL) |
| 234 | { |
| 235 | ImageInfo |
| 236 | *read_info; |
| 237 | |
| 238 | read_info=CloneImageInfo(image_info); |
| 239 | SetImageInfoBlob(read_info,(void *) NULL,0); |
| 240 | (void) CopyMagickString(read_info->filename,image_info->texture, |
| 241 | MaxTextExtent); |
| 242 | texture=ReadImage(read_info,exception); |
| 243 | read_info=DestroyImageInfo(read_info); |
| 244 | } |
| 245 | /* |
| 246 | Annotate the text image. |
| 247 | */ |
cristy | ea1a8aa | 2011-10-20 13:24:06 +0000 | [diff] [blame] | 248 | (void) SetImageBackgroundColor(image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 249 | draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); |
| 250 | (void) CloneString(&draw_info->text,image_info->filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 251 | (void) FormatLocaleString(geometry,MaxTextExtent,"0x0%+ld%+ld",(long) page.x, |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 252 | (long) page.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 253 | (void) CloneString(&draw_info->geometry,geometry); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 254 | status=GetTypeMetrics(image,draw_info,&metrics,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 255 | if (status == MagickFalse) |
| 256 | ThrowReaderException(TypeError,"UnableToGetTypeMetrics"); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 257 | page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 258 | (void) FormatLocaleString(geometry,MaxTextExtent,"0x0%+ld%+ld",(long) page.x, |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 259 | (long) page.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 260 | (void) CloneString(&draw_info->geometry,geometry); |
| 261 | (void) CopyMagickString(filename,image_info->filename,MaxTextExtent); |
| 262 | if (*draw_info->text != '\0') |
| 263 | *draw_info->text='\0'; |
| 264 | p=text; |
| 265 | for (offset=2*page.y; p != (char *) NULL; ) |
| 266 | { |
| 267 | /* |
| 268 | Annotate image with text. |
| 269 | */ |
| 270 | (void) ConcatenateString(&draw_info->text,text); |
| 271 | (void) ConcatenateString(&draw_info->text,"\n"); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 272 | offset+=(ssize_t) (metrics.ascent-metrics.descent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 273 | if (image->previous == (Image *) NULL) |
| 274 | { |
| 275 | status=SetImageProgress(image,LoadImageTag,offset,image->rows); |
| 276 | if (status == MagickFalse) |
| 277 | break; |
| 278 | } |
| 279 | p=ReadBlobString(image,text); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 280 | if ((offset < (ssize_t) image->rows) && (p != (char *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 281 | continue; |
| 282 | if (texture != (Image *) NULL) |
| 283 | { |
| 284 | MagickProgressMonitor |
| 285 | progress_monitor; |
| 286 | |
| 287 | progress_monitor=SetImageProgressMonitor(image, |
| 288 | (MagickProgressMonitor) NULL,image->client_data); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 289 | (void) TextureImage(image,texture,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 290 | (void) SetImageProgressMonitor(image,progress_monitor, |
| 291 | image->client_data); |
| 292 | } |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 293 | (void) AnnotateImage(image,draw_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 294 | if (p == (char *) NULL) |
| 295 | break; |
| 296 | /* |
| 297 | Page is full-- allocate next image structure. |
| 298 | */ |
| 299 | *draw_info->text='\0'; |
| 300 | offset=2*page.y; |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 301 | AcquireNextImage(image_info,image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 302 | if (GetNextImageInList(image) == (Image *) NULL) |
| 303 | { |
| 304 | image=DestroyImageList(image); |
| 305 | return((Image *) NULL); |
| 306 | } |
| 307 | image->next->columns=image->columns; |
| 308 | image->next->rows=image->rows; |
| 309 | image=SyncNextImageInList(image); |
| 310 | (void) CopyMagickString(image->filename,filename,MaxTextExtent); |
cristy | ea1a8aa | 2011-10-20 13:24:06 +0000 | [diff] [blame] | 311 | (void) SetImageBackgroundColor(image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 312 | status=SetImageProgress(image,LoadImagesTag,TellBlob(image), |
| 313 | GetBlobSize(image)); |
| 314 | if (status == MagickFalse) |
| 315 | break; |
| 316 | } |
| 317 | if (texture != (Image *) NULL) |
| 318 | { |
| 319 | MagickProgressMonitor |
| 320 | progress_monitor; |
| 321 | |
| 322 | progress_monitor=SetImageProgressMonitor(image, |
| 323 | (MagickProgressMonitor) NULL,image->client_data); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 324 | (void) TextureImage(image,texture,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 325 | (void) SetImageProgressMonitor(image,progress_monitor,image->client_data); |
| 326 | } |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 327 | (void) AnnotateImage(image,draw_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 328 | if (texture != (Image *) NULL) |
| 329 | texture=DestroyImage(texture); |
| 330 | draw_info=DestroyDrawInfo(draw_info); |
| 331 | (void) CloseBlob(image); |
| 332 | return(GetFirstImageInList(image)); |
| 333 | } |
| 334 | |
| 335 | /* |
| 336 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 337 | % % |
| 338 | % % |
| 339 | % % |
| 340 | % R e a d T X T I m a g e % |
| 341 | % % |
| 342 | % % |
| 343 | % % |
| 344 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 345 | % |
| 346 | % ReadTXTImage() reads a text file and returns it as an image. It allocates |
| 347 | % the memory necessary for the new Image structure and returns a pointer to |
| 348 | % the new image. |
| 349 | % |
| 350 | % The format of the ReadTXTImage method is: |
| 351 | % |
| 352 | % Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) |
| 353 | % |
| 354 | % A description of each parameter follows: |
| 355 | % |
| 356 | % o image_info: the image info. |
| 357 | % |
| 358 | % o exception: return any errors or warnings in this structure. |
| 359 | % |
| 360 | */ |
| 361 | static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) |
| 362 | { |
| 363 | char |
| 364 | colorspace[MaxTextExtent], |
| 365 | text[MaxTextExtent]; |
| 366 | |
| 367 | Image |
| 368 | *image; |
| 369 | |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 370 | long |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 371 | type, |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 372 | x_offset, |
| 373 | y, |
| 374 | y_offset; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 375 | |
cristy | 101ab70 | 2011-10-13 13:06:32 +0000 | [diff] [blame] | 376 | PixelInfo |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | pixel; |
| 378 | |
| 379 | MagickBooleanType |
| 380 | status; |
| 381 | |
| 382 | QuantumAny |
| 383 | range; |
| 384 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 385 | register ssize_t |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 386 | i, |
| 387 | x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 388 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 389 | register Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 390 | *q; |
| 391 | |
| 392 | ssize_t |
| 393 | count; |
| 394 | |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 395 | unsigned long |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 396 | depth, |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 397 | height, |
| 398 | max_value, |
| 399 | width; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 400 | |
| 401 | /* |
| 402 | Open image file. |
| 403 | */ |
| 404 | assert(image_info != (const ImageInfo *) NULL); |
| 405 | assert(image_info->signature == MagickSignature); |
| 406 | if (image_info->debug != MagickFalse) |
| 407 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 408 | image_info->filename); |
| 409 | assert(exception != (ExceptionInfo *) NULL); |
| 410 | assert(exception->signature == MagickSignature); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 411 | image=AcquireImage(image_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 412 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 413 | if (status == MagickFalse) |
| 414 | { |
| 415 | image=DestroyImageList(image); |
| 416 | return((Image *) NULL); |
| 417 | } |
| 418 | (void) ResetMagickMemory(text,0,sizeof(text)); |
| 419 | (void) ReadBlobString(image,text); |
| 420 | if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0) |
| 421 | return(ReadTEXTImage(image_info,image,text,exception)); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 422 | do |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 423 | { |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 424 | *colorspace='\0'; |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 425 | count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%s",&width,&height,&max_value, |
| 426 | colorspace); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 427 | if (count != 4) |
| 428 | ThrowReaderException(CorruptImageError,"ImproperImageHeader"); |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 429 | image->columns=width; |
| 430 | image->rows=height; |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 431 | for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ; |
| 432 | image->depth=depth; |
| 433 | LocaleLower(colorspace); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 434 | i=(ssize_t) strlen(colorspace)-1; |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 435 | image->matte=MagickFalse; |
| 436 | if ((i > 0) && (colorspace[i] == 'a')) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 437 | { |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 438 | colorspace[i]='\0'; |
| 439 | image->matte=MagickTrue; |
| 440 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 441 | type=ParseCommandOption(MagickColorspaceOptions,MagickFalse,colorspace); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 442 | if (type < 0) |
| 443 | ThrowReaderException(CorruptImageError,"ImproperImageHeader"); |
cristy | ea1a8aa | 2011-10-20 13:24:06 +0000 | [diff] [blame] | 444 | (void) SetImageBackgroundColor(image,exception); |
cristy | caf4580 | 2012-06-16 18:28:54 +0000 | [diff] [blame] | 445 | (void) SetImageColorspace(image,(ColorspaceType) type,exception); |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 446 | GetPixelInfo(image,&pixel); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 447 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 448 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 449 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 450 | for (x=0; x < (ssize_t) image->columns; x++) |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 451 | { |
| 452 | if (ReadBlobString(image,text) == (char *) NULL) |
| 453 | break; |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 454 | switch (image->colorspace) |
| 455 | { |
| 456 | case GRAYColorspace: |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 457 | { |
| 458 | if (image->matte != MagickFalse) |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 459 | { |
| 460 | count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf",&x_offset, |
| 461 | &y_offset,&pixel.red,&pixel.alpha); |
| 462 | pixel.green=pixel.red; |
| 463 | pixel.blue=pixel.red; |
| 464 | break; |
| 465 | } |
| 466 | count=(ssize_t) sscanf(text,"%ld,%ld: (%lf",&x_offset,&y_offset, |
| 467 | &pixel.red); |
| 468 | pixel.green=pixel.red; |
| 469 | pixel.blue=pixel.red; |
| 470 | break; |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 471 | } |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 472 | case CMYKColorspace: |
| 473 | { |
| 474 | if (image->matte != MagickFalse) |
| 475 | { |
| 476 | count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf,%lf", |
| 477 | &x_offset,&y_offset,&pixel.red,&pixel.green,&pixel.blue, |
| 478 | &pixel.black,&pixel.alpha); |
| 479 | break; |
| 480 | } |
cristy | 101ab70 | 2011-10-13 13:06:32 +0000 | [diff] [blame] | 481 | count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf",&x_offset, |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 482 | &y_offset,&pixel.red,&pixel.green,&pixel.blue,&pixel.black); |
| 483 | break; |
| 484 | } |
| 485 | default: |
| 486 | { |
| 487 | if (image->matte != MagickFalse) |
| 488 | { |
| 489 | count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf,%lf", |
| 490 | &x_offset,&y_offset,&pixel.red,&pixel.green,&pixel.blue, |
| 491 | &pixel.alpha); |
| 492 | break; |
| 493 | } |
cristy | 101ab70 | 2011-10-13 13:06:32 +0000 | [diff] [blame] | 494 | count=(ssize_t) sscanf(text,"%ld,%ld: (%lf,%lf,%lf",&x_offset, |
cristy | ecd0ab5 | 2010-05-30 14:59:20 +0000 | [diff] [blame] | 495 | &y_offset,&pixel.red,&pixel.green,&pixel.blue); |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 496 | break; |
| 497 | } |
| 498 | } |
| 499 | pixel.red=ScaleAnyToQuantum(pixel.red,range); |
| 500 | pixel.green=ScaleAnyToQuantum(pixel.green,range); |
| 501 | pixel.blue=ScaleAnyToQuantum(pixel.blue,range); |
| 502 | pixel.black=ScaleAnyToQuantum(pixel.black,range); |
| 503 | pixel.alpha=ScaleAnyToQuantum(pixel.alpha,range); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 504 | q=GetAuthenticPixels(image,x_offset,y_offset,1,1,exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 505 | if (q == (Quantum *) NULL) |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 506 | continue; |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 507 | SetPixelInfoPixel(image,&pixel,q); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 508 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 509 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 510 | } |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 511 | } |
| 512 | (void) ReadBlobString(image,text); |
| 513 | if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 514 | { |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 515 | /* |
| 516 | Allocate next image structure. |
| 517 | */ |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 518 | AcquireNextImage(image_info,image,exception); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 519 | if (GetNextImageInList(image) == (Image *) NULL) |
| 520 | { |
| 521 | image=DestroyImageList(image); |
| 522 | return((Image *) NULL); |
| 523 | } |
| 524 | image=SyncNextImageInList(image); |
| 525 | status=SetImageProgress(image,LoadImagesTag,TellBlob(image), |
| 526 | GetBlobSize(image)); |
| 527 | if (status == MagickFalse) |
| 528 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 529 | } |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 530 | } while (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) == 0); |
| 531 | (void) CloseBlob(image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 532 | return(GetFirstImageInList(image)); |
| 533 | } |
| 534 | |
| 535 | /* |
| 536 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 537 | % % |
| 538 | % % |
| 539 | % % |
| 540 | % R e g i s t e r T X T I m a g e % |
| 541 | % % |
| 542 | % % |
| 543 | % % |
| 544 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 545 | % |
| 546 | % RegisterTXTImage() adds attributes for the TXT image format to the |
| 547 | % list of supported formats. The attributes include the image format |
| 548 | % tag, a method to read and/or write the format, whether the format |
| 549 | % supports the saving of more than one frame to the same file or blob, |
| 550 | % whether the format supports native in-memory I/O, and a brief |
| 551 | % description of the format. |
| 552 | % |
| 553 | % The format of the RegisterTXTImage method is: |
| 554 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 555 | % size_t RegisterTXTImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 556 | % |
| 557 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 558 | ModuleExport size_t RegisterTXTImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 559 | { |
| 560 | MagickInfo |
| 561 | *entry; |
| 562 | |
| 563 | entry=SetMagickInfo("TEXT"); |
| 564 | entry->decoder=(DecodeImageHandler *) ReadTXTImage; |
| 565 | entry->encoder=(EncodeImageHandler *) WriteTXTImage; |
| 566 | entry->raw=MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 567 | entry->endian_support=MagickTrue; |
| 568 | entry->description=ConstantString("Text"); |
| 569 | entry->module=ConstantString("TXT"); |
| 570 | (void) RegisterMagickInfo(entry); |
| 571 | entry=SetMagickInfo("TXT"); |
| 572 | entry->decoder=(DecodeImageHandler *) ReadTXTImage; |
| 573 | entry->encoder=(EncodeImageHandler *) WriteTXTImage; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 574 | entry->description=ConstantString("Text"); |
| 575 | entry->magick=(IsImageFormatHandler *) IsTXT; |
| 576 | entry->module=ConstantString("TXT"); |
| 577 | (void) RegisterMagickInfo(entry); |
| 578 | return(MagickImageCoderSignature); |
| 579 | } |
| 580 | |
| 581 | /* |
| 582 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 583 | % % |
| 584 | % % |
| 585 | % % |
| 586 | % U n r e g i s t e r T X T I m a g e % |
| 587 | % % |
| 588 | % % |
| 589 | % % |
| 590 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 591 | % |
| 592 | % UnregisterTXTImage() removes format registrations made by the |
| 593 | % TXT module from the list of supported format. |
| 594 | % |
| 595 | % The format of the UnregisterTXTImage method is: |
| 596 | % |
| 597 | % UnregisterTXTImage(void) |
| 598 | % |
| 599 | */ |
| 600 | ModuleExport void UnregisterTXTImage(void) |
| 601 | { |
| 602 | (void) UnregisterMagickInfo("TEXT"); |
| 603 | (void) UnregisterMagickInfo("TXT"); |
| 604 | } |
| 605 | |
| 606 | /* |
| 607 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 608 | % % |
| 609 | % % |
| 610 | % % |
| 611 | % W r i t e T X T I m a g e % |
| 612 | % % |
| 613 | % % |
| 614 | % % |
| 615 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 616 | % |
| 617 | % WriteTXTImage writes the pixel values as text numbers. |
| 618 | % |
| 619 | % The format of the WriteTXTImage method is: |
| 620 | % |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 621 | % MagickBooleanType WriteTXTImage(const ImageInfo *image_info, |
| 622 | % Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 623 | % |
| 624 | % A description of each parameter follows. |
| 625 | % |
| 626 | % o image_info: the image info. |
| 627 | % |
| 628 | % o image: The image. |
| 629 | % |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 630 | % o exception: return any errors or warnings in this structure. |
| 631 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 632 | */ |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 633 | static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image, |
| 634 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 635 | { |
| 636 | char |
| 637 | buffer[MaxTextExtent], |
| 638 | colorspace[MaxTextExtent], |
| 639 | tuple[MaxTextExtent]; |
| 640 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 | MagickBooleanType |
| 642 | status; |
| 643 | |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 644 | MagickOffsetType |
| 645 | scene; |
| 646 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 647 | PixelInfo |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 648 | pixel; |
| 649 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 650 | register const Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 651 | *p; |
| 652 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 653 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 654 | x; |
| 655 | |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 656 | ssize_t |
| 657 | y; |
| 658 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 659 | /* |
| 660 | Open output image file. |
| 661 | */ |
| 662 | assert(image_info != (const ImageInfo *) NULL); |
| 663 | assert(image_info->signature == MagickSignature); |
| 664 | assert(image != (Image *) NULL); |
| 665 | assert(image->signature == MagickSignature); |
| 666 | if (image->debug != MagickFalse) |
| 667 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 668 | status=OpenBlob(image_info,image,WriteBlobMode,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 669 | if (status == MagickFalse) |
| 670 | return(status); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 671 | scene=0; |
| 672 | do |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 673 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 674 | (void) CopyMagickString(colorspace,CommandOptionToMnemonic( |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 675 | MagickColorspaceOptions,(ssize_t) image->colorspace),MaxTextExtent); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 676 | LocaleLower(colorspace); |
| 677 | image->depth=GetImageQuantumDepth(image,MagickTrue); |
| 678 | if (image->matte != MagickFalse) |
| 679 | (void) ConcatenateMagickString(colorspace,"a",MaxTextExtent); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 680 | (void) FormatLocaleString(buffer,MaxTextExtent, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 681 | "# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n",(double) |
| 682 | image->columns,(double) image->rows,(double) |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 683 | GetQuantumRange(image->depth),colorspace); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 684 | (void) WriteBlobString(image,buffer); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 685 | GetPixelInfo(image,&pixel); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 686 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 687 | { |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 688 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 689 | if (p == (const Quantum *) NULL) |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 690 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 691 | for (x=0; x < (ssize_t) image->columns; x++) |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 692 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 693 | (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g,%.20g: ",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 694 | x,(double) y); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 695 | (void) WriteBlobString(image,buffer); |
cristy | 803640d | 2011-11-17 02:11:32 +0000 | [diff] [blame] | 696 | GetPixelInfoPixel(image,p,&pixel); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 697 | (void) CopyMagickString(tuple,"(",MaxTextExtent); |
cristy | e913961 | 2012-01-03 02:19:10 +0000 | [diff] [blame] | 698 | if (pixel.colorspace == GRAYColorspace) |
| 699 | ConcatenateColorComponent(&pixel,GrayPixelChannel,X11Compliance, |
| 700 | tuple); |
| 701 | else |
| 702 | { |
| 703 | ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance, |
| 704 | tuple); |
| 705 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 706 | ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance, |
| 707 | tuple); |
| 708 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 709 | ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance, |
| 710 | tuple); |
| 711 | } |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 712 | if (pixel.colorspace == CMYKColorspace) |
| 713 | { |
| 714 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 715 | ConcatenateColorComponent(&pixel,BlackPixelChannel,X11Compliance, |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 716 | tuple); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 717 | } |
| 718 | if (pixel.matte != MagickFalse) |
| 719 | { |
| 720 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 721 | ConcatenateColorComponent(&pixel,AlphaPixelChannel,X11Compliance, |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 722 | tuple); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 723 | } |
| 724 | (void) ConcatenateMagickString(tuple,")",MaxTextExtent); |
| 725 | (void) WriteBlobString(image,tuple); |
| 726 | (void) WriteBlobString(image," "); |
| 727 | GetColorTuple(&pixel,MagickTrue,tuple); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 728 | (void) FormatLocaleString(buffer,MaxTextExtent,"%s",tuple); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 729 | (void) WriteBlobString(image,buffer); |
| 730 | (void) WriteBlobString(image," "); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 731 | (void) QueryColorname(image,&pixel,SVGCompliance,tuple,exception); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 732 | (void) WriteBlobString(image,tuple); |
| 733 | (void) WriteBlobString(image,"\n"); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 734 | p+=GetPixelChannels(image); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 735 | } |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 736 | status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, |
cristy | 2aac09a | 2010-06-06 16:46:43 +0000 | [diff] [blame] | 737 | image->rows); |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 738 | if (status == MagickFalse) |
| 739 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 740 | } |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 741 | if (GetNextImageInList(image) == (Image *) NULL) |
| 742 | break; |
| 743 | image=SyncNextImageInList(image); |
| 744 | status=SetImageProgress(image,SaveImagesTag,scene++, |
| 745 | GetImageListLength(image)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 746 | if (status == MagickFalse) |
| 747 | break; |
cristy | 9c7e2af | 2010-05-23 23:13:27 +0000 | [diff] [blame] | 748 | } while (image_info->adjoin != MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 749 | (void) CloseBlob(image); |
| 750 | return(MagickTrue); |
| 751 | } |