/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d M A C I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadMACImage reads an MAC image file and returns it. It % allocates the memory necessary for the new Image structure and returns a % pointer to the new image. % % The format of the ReadMACImage method is: % % Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadMACImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or if % the image cannot be read. % % o image_info: Specifies a pointer to a ImageInfo structure. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception) { Image *image; unsigned int y; unsigned char x8, rep, b; long ldblk; unsigned char *BImgBuff = NULL; unsigned char *DataPtr; unsigned int status; const PixelPacket *q; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image = AllocateImage(image_info); status = OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if(status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); /* Read MAC image. */ ldblk = ReadBlobLSBShort(image); if((ldblk & 0xFF)!=0) ThrowReaderException(CorruptImageError,ImproperImageHeader,image); if(ldblk==0) /* ???? don't know why */ SeekBlob(image,0x200,SEEK_SET); else SeekBlob(image,0x280,SEEK_SET); image->columns = 576; image->rows = 720; image->depth = 1; image->colors = 1l << image->depth; if (!AllocateImageColormap(image,image->colors)) goto NoMemory; /* If ping is true, then only set image size and colors without reading any image data. */ if (image_info->ping) goto DONE_READING; /* ----- Load RLE compressed raster ----- */ ldblk = (image->depth*image->columns) /8; BImgBuff = MagickAllocateMemory(unsigned char *, ((size_t)ldblk)); if(BImgBuff==NULL) NoMemory: ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); DataPtr = BImgBuff; x8=0; y=0; while(y<image->rows) { rep = ReadBlobByte(image); if(EOFBlob(image)) break; if( rep>=128 || rep<=0) { b = ~ReadBlobByte(image);; rep = ~rep + 2; while(rep>0) { *DataPtr++ = b; x8++; rep--; if(x8>=ldblk) { x8=0; q = SetImagePixels(image,0,y,image->columns,1); if(q == (PixelPacket *)NULL) break; (void)ImportImagePixelArea(image,GrayQuantum,1,BImgBuff,NULL,0); if(!SyncImagePixels(image)) break; DataPtr = BImgBuff; y++; if(y>=image->rows) { break; } } } } else { rep++; while(rep>0) { b = ~ReadBlobByte(image); *DataPtr++ = b; x8++; rep--; if(x8>=ldblk) { x8=0; q = SetImagePixels(image,0,y,image->columns,1); if(q == (PixelPacket *)NULL) break; (void)ImportImagePixelArea(image,GrayQuantum,1,BImgBuff,NULL,0); if (!SyncImagePixels(image)) break; DataPtr = BImgBuff; y++; if(y>=image->rows) { break; } } } } } if(BImgBuff!=NULL) MagickFreeMemory(BImgBuff); if(EOFBlob(image)) ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename); DONE_READING: CloseBlob(image); return(image); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d C M Y K I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadCMYKImage reads an image of raw cyan, magenta, yellow, and black % samples and returns it. It allocates the memory necessary for the new % Image structure and returns a pointer to the new image. % % The format of the ReadCMYKImage method is: % % Image *ReadCMYKImage(const ImageInfo *image_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadCMYKImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or % if the image cannot be read. % % o image_info: Specifies a pointer to a ImageInfo structure. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadCMYKImage(const ImageInfo *image_info, ExceptionInfo *exception) { Image *image; long y; register long i, x; register PixelPacket *q; size_t count; unsigned char *scanline; unsigned int status; unsigned int packet_size, quantum_size; ImportPixelAreaOptions import_options; assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AllocateImage(image_info); if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,MustSpecifyImageSize,image); if (image_info->interlace != PartitionInterlace) { /* Open image file. */ status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); for (i=0; i < image->offset; i++) { if (EOF == ReadBlobByte(image)) ThrowException(exception,CorruptImageError,UnexpectedEndOfFile, image->filename); } } if (image->logging) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Tile %lux%lu%+ld%+ld", image->tile_info.width,image->tile_info.height, image->tile_info.x,image->tile_info.y); /* Allocate memory for a scanline. */ if (image->depth <= 8) quantum_size=8; else if (image->depth <= 16) quantum_size=16; else quantum_size=32; packet_size=(quantum_size*4)/8; if (LocaleCompare(image_info->magick,"CMYKA") == 0) { image->matte=True; packet_size=(quantum_size*5)/8; } scanline=MagickAllocateArray(unsigned char *, packet_size,image->tile_info.width); if (scanline == (unsigned char *) NULL) ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); /* Initialize import options. */ ImportPixelAreaOptionsInit(&import_options); if (image_info->endian != UndefinedEndian) import_options.endian=image_info->endian; if (image->logging) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Depth %u bits, Endian %s, Interlace %s", quantum_size, EndianTypeToString(import_options.endian), InterlaceTypeToString(image_info->interlace)); /* Support starting at intermediate image frame. */ if (image_info->subrange != 0) while (image->scene < image_info->subimage) { /* Skip to next image. */ image->scene++; for (y=0; y < (long) image->rows; y++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); } x=(long) (packet_size*image->tile_info.x); do { /* Convert raster image to pixel packets. */ image->colorspace=CMYKColorspace; if (image_info->ping && (image_info->subrange != 0)) if (image->scene >= (image_info->subimage+image_info->subrange-1)) break; switch (image_info->interlace) { case NoInterlace: default: { /* No interlacing: CMYKCMYKCMYKCMYKCMYKCMYK... */ for (y=0; y < image->tile_info.y; y++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); for (y=0; y < (long) image->rows; y++) { if ((y > 0) || (image->previous == (Image *) NULL)) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); q=SetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; if (!image->matte) (void) ImportImagePixelArea(image,CMYKQuantum,quantum_size,scanline+x, &import_options,0); else (void) ImportImagePixelArea(image,CMYKAQuantum,quantum_size,scanline+x, &import_options,0); if (!SyncImagePixels(image)) break; if (image->previous == (Image *) NULL) if (QuantumTick(y,image->rows)) if (!MagickMonitorFormatted(y,image->rows,exception, LoadImageText,image->filename, image->columns,image->rows)) break; } count=image->tile_info.height-image->rows-image->tile_info.y; for (i=0; i < (long) count; i++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); break; } case LineInterlace: { /* Line interlacing: CCC...MMM...YYY...KKK...CCC...MMM...YYY...KKK... */ packet_size=(quantum_size)/8; for (y=0; y < image->tile_info.y; y++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); for (y=0; y < (long) image->rows; y++) { if ((y > 0) || (image->previous == (Image *) NULL)) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); q=SetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; (void) ImportImagePixelArea(image,CyanQuantum,quantum_size,scanline+x, &import_options,0); (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); (void) ImportImagePixelArea(image,MagentaQuantum,quantum_size,scanline+x, &import_options,0); (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); (void) ImportImagePixelArea(image,YellowQuantum,quantum_size,scanline+x, &import_options,0); (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); (void) ImportImagePixelArea(image,BlackQuantum,quantum_size,scanline+x, &import_options,0); if (image->matte) { (void) ReadBlob(image,packet_size*image->tile_info.width, scanline); (void) ImportImagePixelArea(image,AlphaQuantum,quantum_size,scanline+x, &import_options,0); } if (!SyncImagePixels(image)) break; if (image->previous == (Image *) NULL) if (QuantumTick(y,image->rows)) if (!MagickMonitorFormatted(y,image->rows,exception, LoadImageText,image->filename, image->columns,image->rows)) break; } count=image->tile_info.height-image->rows-image->tile_info.y; for (i=0; i < (long) count; i++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); break; } case PlaneInterlace: case PartitionInterlace: { unsigned long span; /* Plane interlacing: CCCCCC...MMMMMM...YYYYYY...KKKKKK... */ if (image_info->interlace == PartitionInterlace) { AppendImageFormat("C",image->filename); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); } packet_size=(quantum_size)/8; for (y=0; y < image->tile_info.y; y++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); i=0; span=image->rows*(image->matte ? 5 : 4); for (y=0; y < (long) image->rows; y++) { if ((y > 0) || (image->previous == (Image *) NULL)) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); q=SetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; (void) ImportImagePixelArea(image,CyanQuantum,quantum_size,scanline+x, &import_options,0); if (!SyncImagePixels(image)) break; if (image->previous == (Image *) NULL) if (QuantumTick(i,span)) if (!MagickMonitorFormatted(i,span,&image->exception, LoadImageText,image->filename, image->columns,image->rows)) break; i++; } count=image->tile_info.height-image->rows-image->tile_info.y; for (i=0; i < (long) count; i++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); if (image_info->interlace == PartitionInterlace) { CloseBlob(image); AppendImageFormat("M",image->filename); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); } for (y=0; y < image->tile_info.y; y++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); for (y=0; y < (long) image->rows; y++) { (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); q=GetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; (void) ImportImagePixelArea(image,MagentaQuantum,quantum_size,scanline+x, &import_options,0); if (!SyncImagePixels(image)) break; if (image->previous == (Image *) NULL) if (QuantumTick(i,span)) if (!MagickMonitorFormatted(i,span,&image->exception, LoadImageText,image->filename, image->columns,image->rows)) break; i++; } count=image->tile_info.height-image->rows-image->tile_info.y; for (i=0; i < (long) count; i++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); if (image_info->interlace == PartitionInterlace) { CloseBlob(image); AppendImageFormat("Y",image->filename); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); } for (y=0; y < image->tile_info.y; y++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); for (y=0; y < (long) image->rows; y++) { (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); q=GetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; (void) ImportImagePixelArea(image,YellowQuantum,quantum_size,scanline+x, &import_options,0); if (!SyncImagePixels(image)) break; if (image->previous == (Image *) NULL) if (QuantumTick(i,span)) if (!MagickMonitorFormatted(i,span,&image->exception, LoadImageText,image->filename, image->columns,image->rows)) break; i++; } count=image->tile_info.height-image->rows-image->tile_info.y; for (i=0; i < (long) count; i++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); if (image_info->interlace == PartitionInterlace) { CloseBlob(image); AppendImageFormat("K",image->filename); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); } for (y=0; y < image->tile_info.y; y++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); for (y=0; y < (long) image->rows; y++) { (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); q=GetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; (void) ImportImagePixelArea(image,BlackQuantum,quantum_size,scanline+x, &import_options,0); if (!SyncImagePixels(image)) break; if (image->previous == (Image *) NULL) if (QuantumTick(i,span)) if (!MagickMonitorFormatted(i,span,&image->exception, LoadImageText,image->filename, image->columns,image->rows)) break; i++; } count=image->tile_info.height-image->rows-image->tile_info.y; for (i=0; i < (long) count; i++) (void) ReadBlob(image,packet_size*image->tile_info.width,scanline); if (image->matte) { /* Read matte channel. */ if (image_info->interlace == PartitionInterlace) { CloseBlob(image); AppendImageFormat("A",image->filename); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); } for (y=0; y < image->tile_info.y; y++) (void) ReadBlob(image,packet_size*image->tile_info.width, scanline); for (y=0; y < (long) image->rows; y++) { (void) ReadBlob(image,packet_size*image->tile_info.width, scanline); q=GetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; (void) ImportImagePixelArea(image,AlphaQuantum,quantum_size,scanline+x, &import_options,0); if (!SyncImagePixels(image)) break; if (image->previous == (Image *) NULL) if (QuantumTick(i,span)) if (!MagickMonitorFormatted(i,span,&image->exception, LoadImageText,image->filename, image->columns,image->rows)) break; i++; } count=image->tile_info.height-image->rows-image->tile_info.y; for (i=0; i < (long) count; i++) (void) ReadBlob(image,packet_size*image->tile_info.width, scanline); } if (image_info->interlace == PartitionInterlace) (void) strlcpy(image->filename,image_info->filename,MaxTextExtent); break; } } if (EOFBlob(image)) { ThrowException(exception,CorruptImageError,UnexpectedEndOfFile, image->filename); break; } /* Proceed to next image. */ if (image_info->subrange != 0) if (image->scene >= (image_info->subimage+image_info->subrange-1)) break; if (image_info->interlace == PartitionInterlace) break; count=ReadBlob(image,packet_size*image->tile_info.width,scanline); if (count != 0) { /* Allocate next image structure. */ AllocateNextImage(image_info,image); if (image->next == (Image *) NULL) { DestroyImageList(image); return((Image *) NULL); } image=SyncNextImageInList(image); status=MagickMonitorFormatted(TellBlob(image),GetBlobSize(image), exception,LoadImagesText, image->filename); if (status == False) break; } } while (count != 0); MagickFreeMemory(scanline); while (image->previous != (Image *) NULL) image=image->previous; CloseBlob(image); return(image); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d A R T I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadARTImage reads an ART X image file and returns it. It % allocates the memory necessary for the new Image structure and returns a % pointer to the new image. % % The format of the ReadARTImage method is: % % Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadARTImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or if % the image cannot be read. % % o image_info: Specifies a pointer to a ImageInfo structure. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) { Image *image; int i; unsigned width,height,dummy; long ldblk; unsigned char *BImgBuff=NULL; unsigned char Padding; unsigned int status; const PixelPacket *q; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AllocateImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); /* Read ART image. */ dummy=ReadBlobLSBShort(image); width=ReadBlobLSBShort(image); dummy=ReadBlobLSBShort(image); height=ReadBlobLSBShort(image); ldblk=(long) ((width+7) / 8); Padding=(unsigned char) ((-ldblk) & 0x01); if(GetBlobSize(image)!=(8+((long)ldblk+Padding)*height)) ThrowReaderException(CorruptImageError,ImproperImageHeader,image); image->columns=width; image->rows=height; image->depth=1; image->colors=1l << image->depth; /* printf("ART header checked OK %d,%d\n",image->colors,image->depth); */ if (!AllocateImageColormap(image,image->colors)) goto NoMemory; /* If ping is true, then only set image size and colors without reading any image data. */ if (image_info->ping) goto DONE_READING; /* ----- Load RLE compressed raster ----- */ BImgBuff=MagickAllocateMemory(unsigned char *,((size_t) ldblk)); /*Ldblk was set in the check phase*/ if(BImgBuff==NULL) NoMemory: ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); for(i=0; i<(int)height; i++) { (void) ReadBlob(image,(size_t)ldblk,(char *)BImgBuff); (void) ReadBlob(image,Padding,(char *)&dummy); q=SetImagePixels(image,0,i,image->columns,1); if (q == (PixelPacket *)NULL) break; (void)ImportImagePixelArea(image,GrayQuantum,1,BImgBuff,NULL,0); if (!SyncImagePixels(image)) break; } if(BImgBuff!=NULL) MagickFreeMemory(BImgBuff); if (EOFBlob(image)) ThrowException(exception,CorruptImageError,UnexpectedEndOfFile, image->filename); DONE_READING: CloseBlob(image); return(image); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d T X T I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadTXTImage reads a text file and returns it as an image. It % allocates the memory necessary for the new Image structure and returns a % pointer to the new image. % % The format of the ReadTXTImage method is: % % Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadTXTImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or if % the image cannot be read. % % o image_info: Specifies a pointer to a ImageInfo structure. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) { char *p, text[MaxTextExtent]; Image *image; TXT_TYPE txt_subformat; MagickPassFail status; MagickBool logging; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); logging = IsEventLogging(); image=AllocateImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); p = ReadBlobString(image,text); if (p == NULL) ThrowReaderException(CorruptImageError,ImproperImageHeader,image); txt_subformat = IsTXT((unsigned char *)p,strlen(p)); if (txt_subformat != NO_TXT) { unsigned x, y; unsigned x_min, x_max, y_curr; int ch; unsigned long max, i; char NumOfPlanes; unsigned char *BImgBuff; magick_uint16_t *WImgBuff; magick_uint32_t *DImgBuff; magick_uint32_t R, G, B, A; const PixelPacket *q; ExtendedSignedIntegralType NextImagePos = 0; ImportPixelAreaOptions import_options; if (logging) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "File RAW TXT type: %d", (int) txt_subformat); do { (void) SeekBlob(image,NextImagePos,SEEK_SET); if(NextImagePos!=0) { /* Allocate next image structure. */ AllocateNextImage(image_info,image); if(image->next == (Image *)NULL) break; image = SyncNextImageInList(image); image->columns = image->rows = 0; image->colors=0; } A=0; x=0; y=0; max=0; switch(txt_subformat) { case TXT_GM8B_HEX: case TXT_GM8B_HEX_Q: max=255; break; case TXT_GM16B_HEX: case TXT_GM16B_HEX_Q: max=65535; break; case TXT_GM32B_HEX: case TXT_GM32B_HEX_Q: max=65536; break; default: break; } /* Set opacity flag. */ image->matte=MagickFalse; if (txt_subformat >= IMAGEMAGICK_TXT_Q) image->matte=MagickTrue; if (!strncmp(p,"# ImageMagick pixel enumeration:",32)) { if (sscanf(p+32,"%u,%u,%u",&x_min,&y_curr,&x_max) == 3) { if (strstr(p+32,",rgb")!=NULL) { x = x_min-1; y = y_curr-1; max = x_max; } if (strstr(p+32,",rgba")!=NULL) { txt_subformat = IMAGEMAGICK_TXT_Q; } } } ch=0; if (x == 0 && y == 0) while (!EOFBlob(image)) /* auto detect sizes and num of planes */ { while (!(ch >= '0' && ch <= '9')) { /* go to the begin of number */ ch = ReadBlobByte(image); if (ch == EOF) goto EndReading; if (ch == '#') { readln(image,&ch); continue; } if (ch == 0 || ch > 128 || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { TXT_FAIL: /* not a text data */ ThrowReaderException(CoderError,ImageTypeNotSupported,image); } } /* x,y: (R,G,B) */ x_min = ReadInt(image,&ch); /* x */ if (x_min > x) x = x_min; while (ch != ',') { ch = ReadBlobByte(image); if (ch==EOF) break; if (ch == 10 || ch == 13) goto TXT_FAIL; } ch=0; i=ReadInt(image,&ch); /* y */ /* Check for next image start. */ if(x_min==0 && i==0 && x>0 && y>0) goto EndReading; if (i > y) y=i; while (ch != ':') { ch = ReadBlobByte(image); if (ch == 10 || ch == 13) goto TXT_FAIL; if (ch == EOF) break; } if (txt_subformat != TXT_GM8B_PLAIN2_Q) while (ch != '(') { ch = ReadBlobByte(image); if (ch == 10 || ch == 13) goto TXT_FAIL; if (ch == EOF) break; } ch=0; R = ReadInt(image,&ch); /* R */ if (R > max) max=R; while (ch != ',') { ch = ReadBlobByte(image); if (ch == 10 || ch == 13) goto TXT_FAIL; if (ch == EOF) break; } ch=0; G = ReadInt(image,&ch); /* G */ if (G > max) max=G; while (ch != ',') { ch = ReadBlobByte(image); if (ch == 10 || ch == 13) goto TXT_FAIL; if (ch == EOF) break; } ch=0; B = ReadInt(image,&ch); /* B */ if (B > max) max=B; if (txt_subformat >= IMAGEMAGICK_TXT_Q) { while (ch != ',') { ch = ReadBlobByte(image); if (ch == 10 || ch == 13) goto TXT_FAIL; if (ch == EOF) break; } ch=0; A = ReadInt(image,&ch); /* A */ if (A > max) max=A; } if (txt_subformat != TXT_GM8B_PLAIN2_Q) while (ch != ')') { ch = ReadBlobByte(image); if (ch == 10 || ch == 13) goto TXT_FAIL; if (ch == EOF) break; } readln(image,&ch); } EndReading: x_min = 1; x_max = 0; y_curr = 0; NumOfPlanes=8; /* if (max>= 2) NumOfPlanes=2; */ /* if (max>= 4) NumOfPlanes=4; */ /* if (max>= 16) NumOfPlanes=8; */ if (max >= 256) NumOfPlanes=16; if (max >=65536) NumOfPlanes=32; if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), "Image detected [%u * %u]: %d", x, y, NumOfPlanes); image->depth = Min(QuantumDepth,NumOfPlanes); ImportPixelAreaOptionsInit(&import_options); import_options.endian = NativeEndian; BImgBuff = MagickAllocateArray(unsigned char *, (size_t)(x+1), ( ((image->matte) ? 4 : 3) * NumOfPlanes/8)); WImgBuff = (magick_uint16_t *)BImgBuff; DImgBuff = (magick_uint32_t *)BImgBuff; if (BImgBuff == NULL) ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); image->columns = x+1; image->rows = y+1; (void) SeekBlob(image,NextImagePos,SEEK_SET); NextImagePos = 0; /* Load picture data */ while (!EOFBlob(image)) { x=0; while (!(ch >= '0' && ch <= '9')) { /* move to the beginning of number */ if (EOFBlob(image)) goto FINISH; ch = ReadBlobByte(image); if (ch == '#') { readln(image,&ch); continue; } } x = ReadInt(image,&ch); /* x */ while (ch != ',') { ch = ReadBlobByte(image); if (ch == EOF) break; } ch = 0; y = ReadInt(image,&ch); /* y */ /* New image detected. */ if(x==0 && y==0 && y_curr>0 && x_max>0) { NextImagePos = TellBlob(image) - 4; break; } while (ch != ':') { ch = ReadBlobByte(image); if (ch == EOF) break; } while (ch != '(') { ch = ReadBlobByte(image); if (ch == EOF) break; } ch=0; R = ReadInt(image,&ch); /* R */ while (ch != ',') { ch = ReadBlobByte(image); if (ch == EOF) break; } ch=0; G = ReadInt(image,&ch); /* G */ while (ch != ',') { ch = ReadBlobByte(image); if (ch == EOF) break; } ch=0; B = ReadInt(image,&ch); /* B */ if (image->matte) { while (ch != ',') { ch = ReadBlobByte(image); if (ch == EOF) break; } ch=0; A = ReadInt(image,&ch); /* A */ if (A > max) max=A; } while (ch != ')') { ch = ReadBlobByte(image); if (ch == EOF) break; } /* A new line has been detected */ if (y != y_curr) { q = SetImagePixels(image,x_min,y_curr,x_max-x_min+1,1); if (q == (PixelPacket *)NULL) break; if (image->matte) (void)ImportImagePixelArea(image,RGBAQuantum,NumOfPlanes, BImgBuff + 4*x_min*(NumOfPlanes/8), &import_options,0); else (void)ImportImagePixelArea(image,RGBQuantum,NumOfPlanes, BImgBuff + 3*x_min*(NumOfPlanes/8), &import_options,0); if (!SyncImagePixels(image)) break; x_min = 1; x_max = 0; y_curr=y; } if (x < image->columns) { if (image->matte) { switch(NumOfPlanes) { case 8: BImgBuff[0+4*x] = R; BImgBuff[1+4*x] = G; BImgBuff[2+4*x] = B; BImgBuff[3+4*x] = 255U-A; break; case 16: WImgBuff[0+4*x] = R; WImgBuff[1+4*x] = G; WImgBuff[2+4*x] = B; WImgBuff[3+4*x] = 65535U-A; break; case 32: DImgBuff[0+4*x] = R; DImgBuff[1+4*x] = G; DImgBuff[2+4*x] = B; DImgBuff[3+4*x] = 4294967295U-A; break; } } else { switch(NumOfPlanes) { case 8: BImgBuff[0+3*x] = R; BImgBuff[1+3*x] = G; BImgBuff[2+3*x] = B; break; case 16: WImgBuff[0+3*x] = R; WImgBuff[1+3*x] = G; WImgBuff[2+3*x] = B; break; case 32: DImgBuff[0+3*x] = R; DImgBuff[1+3*x] = G; DImgBuff[2+3*x] = B; break; } } if (x_min > x_max) { x_max=x_min=x; } else { if (x < x_min) x_min=x; if (x > x_max) x_max=x; } } readln(image,&ch); } FINISH: if (x_min <= x_max) { q = SetImagePixels(image,x_min,y_curr,x_max-x_min+1,1); if (q != (PixelPacket *)NULL) { if (image->matte) (void)ImportImagePixelArea(image, RGBAQuantum, NumOfPlanes, BImgBuff + 4*x_min*(NumOfPlanes/8), &import_options, 0); else (void)ImportImagePixelArea(image, RGBQuantum, NumOfPlanes, BImgBuff + 3*x_min*(NumOfPlanes/8), &import_options, 0); if (!SyncImagePixels(image)) { if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), " TXT failed to sync image pixels for a row %u", y_curr); } } } MagickFreeMemory(BImgBuff); } while(!EOFBlob(image) && NextImagePos>0); goto FINISH_TXT; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d V I C A R I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadVICARImage reads a VICAR image file and returns it. It % allocates the memory necessary for the new Image structure and returns a % pointer to the new image. % % The format of the ReadVICARImage method is: % % Image *ReadVICARImage(const ImageInfo *image_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadVICARImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or if % the image cannot be read. % % o image_info: Specifies a pointer to a ImageInfo structure. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadVICARImage(const ImageInfo *image_info, ExceptionInfo *exception) { char keyword[MaxTextExtent], value[MaxTextExtent]; Image *image; int c, y; long count; unsigned char *scanline; unsigned int status, value_expected; unsigned long length; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AllocateImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); /* Decode image header. */ c=ReadBlobByte(image); count=1; if (c == EOF) { DestroyImage(image); return((Image *) NULL); } length=0; image->columns=0; image->rows=0; while (isgraph(c) && ((image->columns == 0) || (image->rows == 0))) { if (!isalnum(c)) { c=ReadBlobByte(image); count++; } else { register char *p; /* Determine a keyword and its value. */ p=keyword; do { if ((p-keyword) < (MaxTextExtent-1)) *p++=c; c=ReadBlobByte(image); count++; } while (isalnum(c) || (c == '_')); *p='\0'; value_expected=False; while (isspace(c) || (c == '=')) { if (c == '=') value_expected=True; c=ReadBlobByte(image); count++; } if (value_expected == False) continue; p=value; while (isalnum(c)) { if ((p-value) < (MaxTextExtent-1)) *p++=c; c=ReadBlobByte(image); count++; } *p='\0'; /* Assign a value to the specified keyword. */ if (LocaleCompare(keyword,"Label_RECORDS") == 0) length=MagickAtoL(value); if (LocaleCompare(keyword,"LBLSIZE") == 0) length=MagickAtoL(value); if (LocaleCompare(keyword,"RECORD_BYTES") == 0) image->columns= MagickAtoL(value); if (LocaleCompare(keyword,"NS") == 0) image->columns= MagickAtoL(value); if (LocaleCompare(keyword,"LINES") == 0) image->rows= MagickAtoL(value); if (LocaleCompare(keyword,"NL") == 0) image->rows= MagickAtoL(value); } while (isspace(c)) { c=ReadBlobByte(image); count++; } } while (count < (long) length) { c=ReadBlobByte(image); count++; } if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image); image->depth=8; if (!AllocateImageColormap(image,256)) ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); if (image_info->ping) { CloseBlob(image); return(image); } /* Read VICAR pixels. */ scanline=MagickAllocateMemory(unsigned char *,image->columns); if (scanline == (unsigned char *) NULL) ThrowReaderException(CorruptImageError,UnableToReadImageData,image); for (y=0; y < (long) image->rows; y++) { if (!SetImagePixels(image,0,y,image->columns,1)) break; (void) ReadBlob(image,image->columns,scanline); (void) ImportImagePixelArea(image,GrayQuantum,image->depth,scanline,0,0); if (!SyncImagePixels(image)) break; if (QuantumTick(y,image->rows)) if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText, image->filename, image->columns,image->rows)) break; } MagickFreeMemory(scanline); if (EOFBlob(image)) ThrowException(exception,CorruptImageError,UnexpectedEndOfFile, image->filename); CloseBlob(image); return(image); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d T X T I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadTXTImage reads a text file and returns it as an image. It % allocates the memory necessary for the new Image structure and returns a % pointer to the new image. % % The format of the ReadTXTImage method is: % % Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadTXTImage returns a pointer to the image after % reading. A null image is returned if there is a memory shortage or if % the image cannot be read. % % o image_info: Specifies a pointer to a ImageInfo structure. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) { char filename[MaxTextExtent], geometry[MaxTextExtent], *p, text[MaxTextExtent]; double dx_resolution, dy_resolution; DrawInfo *draw_info; Image *image, *texture; long count, offset; RectangleInfo page; TypeMetric metrics; unsigned int status; int logging; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter"); image=AllocateImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); p = ReadBlobString(image,text); status = IsTXT((unsigned char *)p,strlen(p)); if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), "File type: %d", status); if(status) { unsigned x,y; unsigned x_min,x_max,y_curr; int ch; unsigned long max,i; char NumOfPlanes; unsigned char *BImgBuff; magick_uint16_t *WImgBuff; magick_uint32_t *DImgBuff; magick_uint32_t R,G,B,A; const PixelPacket *q; ImportPixelAreaOptions import_options; (void) SeekBlob(image,0,SEEK_SET); A=0; x=0; y=0; max=0; switch(status) { case TXT_GM8B_HEX: case TXT_GM8B_HEX_Q: max=255; break; case TXT_GM16B_HEX: case TXT_GM16B_HEX_Q: max=65535; break; case TXT_GM32B_HEX: case TXT_GM32B_HEX_Q: max=65536; break; } if(!strncmp(p,"# ImageMagick pixel enumeration:",32)) { if(sscanf(p+32,"%u,%u,%u",&x_min,&y_curr,&x_max)==3) { if(strstr(p+32,",rgb")!=NULL) { x = x_min-1; y = y_curr-1; max = x_max; } if(strstr(p+32,",rgba")!=NULL) { status = IMAGEMAGICK_TXT_Q; } } } ch=0; if(x==0 && y==0) while(!EOFBlob(image)) /* auto detect sizes and num of planes */ { while(!(ch>='0' && ch<='9')) { /* go to the begin of number */ ch = ReadBlobByte(image); if(ch==EOF) goto EndReading; if(ch=='#') {readln(image,&ch); continue;} if(ch==0 || ch>128 || (ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) { TXT_FAIL: /* not a text data */ ThrowReaderException(CoderError,ImageTypeNotSupported,image); } } /* x,y: (R,G,B) */ i = ReadInt(image,&ch); /* x */ if(i>x) x=i; while(ch!=',') { ch = ReadBlobByte(image); if(ch==EOF) break; if(ch==10 || ch==13) goto TXT_FAIL; } ch=0; i=ReadInt(image,&ch); /* y */ if(i>y) y=i; while(ch!=':') { ch = ReadBlobByte(image); if(ch==10 || ch==13) goto TXT_FAIL; if(ch==EOF) break; } if(status!=TXT_GM8B_PLAIN2_Q) while(ch!='(') { ch = ReadBlobByte(image); if(ch==10 || ch==13) goto TXT_FAIL; if(ch==EOF) break; } ch=0; R = ReadInt(image,&ch); /* R */ if(R>max) max=R; while(ch!=',') { ch = ReadBlobByte(image); if(ch==10 || ch==13) goto TXT_FAIL; if(ch==EOF) break; } ch=0; G = ReadInt(image,&ch); /* G */ if(G>max) max=G; while(ch!=',') { ch = ReadBlobByte(image); if(ch==10 || ch==13) goto TXT_FAIL; if(ch==EOF) break; } ch=0; B = ReadInt(image,&ch); /* B */ if(B>max) max=B; if(status>16) { while(ch!=',') { ch = ReadBlobByte(image); if(ch==10 || ch==13) goto TXT_FAIL; if(ch==EOF) break; } ch=0; A = ReadInt(image,&ch); /* A */ if(A>max) max=A; } if(status!=TXT_GM8B_PLAIN2_Q) while(ch!=')') { ch = ReadBlobByte(image); if(ch==10 || ch==13) goto TXT_FAIL; if(ch==EOF) break; } readln(image,&ch); } EndReading: x_min = 1; x_max = 0; y_curr = 0; NumOfPlanes=8; /* if(max>= 2) i=2; */ /* if(max>= 4) i=4; */ /* if(max>= 16) i=8; */ if(max>= 256) NumOfPlanes=16; if(max>=65536) NumOfPlanes=32; if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), "Image detected [%u * %u]: %d", x, y, NumOfPlanes); image->depth = Min(QuantumDepth,NumOfPlanes); ImportPixelAreaOptionsInit(&import_options); import_options.endian = NativeEndian; BImgBuff = MagickAllocateMemory(unsigned char *, (size_t)(x+1) * ( ((status>16)?4:3) * NumOfPlanes/8)); WImgBuff = (magick_uint16_t *)BImgBuff; DImgBuff = (magick_uint32_t *)BImgBuff; if(BImgBuff==NULL) ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); image->columns = x+1; image->rows = y+1; (void) SeekBlob(image,0,SEEK_SET); while(!EOFBlob(image)) /* load picture data */ { x=0; while(!(ch >= '0' && ch <= '9')) { /* move to the beginning of number */ if(EOFBlob(image)) goto FINISH; ch = ReadBlobByte(image); if(ch=='#') {readln(image,&ch); continue;} } x = ReadInt(image,&ch); /* x */ while(ch!=',') { ch = ReadBlobByte(image); if(ch==EOF) break; } ch = 0; y = ReadInt(image,&ch); /* y */ while(ch!=':') { ch = ReadBlobByte(image); if(ch==EOF) break; } while(ch!='(') { ch = ReadBlobByte(image); if(ch==EOF) break; } ch=0; R = ReadInt(image,&ch); /* R */ while(ch!=',') { ch = ReadBlobByte(image); if(ch==EOF) break; } ch=0; G = ReadInt(image,&ch); /* G */ while(ch!=',') { ch = ReadBlobByte(image); if(ch==EOF) break; } ch=0; B = ReadInt(image,&ch); /* B */ if(status>16) { while(ch!=',') { ch = ReadBlobByte(image); if(ch==EOF) break; } ch=0; A = ReadInt(image,&ch); /* A */ if(A>max) max=A; } while(ch!=')') { ch = ReadBlobByte(image); if(ch==EOF) break; } /* a new line has been detected */ if(y!=y_curr) { q = SetImagePixels(image,x_min,y_curr,x_max-x_min+1,1); if (q == (PixelPacket *)NULL) break; if(status>16) (void)ImportImagePixelArea(image,RGBAQuantum,NumOfPlanes, BImgBuff + 4*x_min*(NumOfPlanes/8),&import_options,0); else (void)ImportImagePixelArea(image,RGBQuantum,NumOfPlanes, BImgBuff + 3*x_min*(NumOfPlanes/8),&import_options,0); if (!SyncImagePixels(image)) break; x_min = 1; x_max = 0; y_curr=y; } if(x<image->columns) { if(status>16) { switch(NumOfPlanes) { case 8: BImgBuff[0+4*x] = R; BImgBuff[1+4*x] = G; BImgBuff[2+4*x] = B; BImgBuff[3+4*x] = A; break; case 16:WImgBuff[0+4*x] = R; WImgBuff[1+4*x] = G; WImgBuff[2+4*x] = B; WImgBuff[3+4*x] = A; break; case 32:DImgBuff[0+4*x] = R; DImgBuff[1+4*x] = G; DImgBuff[2+4*x] = B; DImgBuff[3+4*x] = A; break; } } else { switch(NumOfPlanes) { case 8: BImgBuff[0+3*x] = R; BImgBuff[1+3*x] = G; BImgBuff[2+3*x] = B; break; case 16:WImgBuff[0+3*x] = R; WImgBuff[1+3*x] = G; WImgBuff[2+3*x] = B; break; case 32:DImgBuff[0+3*x] = R; DImgBuff[1+3*x] = G; DImgBuff[2+3*x] = B; break; } } if(x_min>x_max) x_max=x_min=x; else { if(x<x_min) x_min=x; if(x>x_max) x_max=x; } } readln(image,&ch); } FINISH: if(x_min<=x_max) { q = SetImagePixels(image,x_min,y_curr,x_max-x_min+1,1); if (q != (PixelPacket *)NULL) { if(status>16) (void)ImportImagePixelArea(image, RGBAQuantum, NumOfPlanes, BImgBuff + 4*x_min*(NumOfPlanes/8), &import_options, 0); else (void)ImportImagePixelArea(image, RGBQuantum, NumOfPlanes, BImgBuff + 3*x_min*(NumOfPlanes/8), &import_options, 0); if(!SyncImagePixels(image)) { if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), " TXT failed to sync image pixels for a row %u", y_curr); } } } MagickFreeMemory(BImgBuff); goto TXT_FINISH; } /* Set the page geometry. */ dx_resolution=72.0; dy_resolution=72.0; if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0)) { char density[MaxTextExtent]; (void) strcpy(density,PSDensityGeometry); count=GetMagickDimension(density,&image->x_resolution, &image->y_resolution,NULL,NULL); if (count != 2) image->y_resolution=image->x_resolution; } SetGeometry(image,&page); page.width=612; page.height=792; (void) GetGeometry("612x792+43+43",&page.x,&page.y,&page.width,&page.height); if (image_info->page != (char *) NULL) (void) GetGeometry(image_info->page,&page.x,&page.y,&page.width, &page.height); /* Initialize Image structure. */ image->columns=(unsigned long) ceil(((page.width*image->x_resolution)/dx_resolution)-0.5); image->rows=(unsigned long) ceil(((page.height*image->y_resolution)/dy_resolution)-0.5); texture=(Image *) NULL; if (image_info->texture != (char *) NULL) { ImageInfo *clone_info; clone_info=CloneImageInfo(image_info); clone_info->blob=(void *) NULL; clone_info->length=0; (void) strlcpy(clone_info->filename,image_info->texture,MaxTextExtent); texture=ReadImage(clone_info,exception); DestroyImageInfo(clone_info); } /* Annotate the text image. */ (void) SetImage(image,OpaqueOpacity); draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); draw_info->fill=image_info->pen; (void) CloneString(&draw_info->text,image_info->filename); FormatString(geometry,"0x0%+ld%+ld",page.x,page.y); (void) CloneString(&draw_info->geometry,geometry); status=GetTypeMetrics(image,draw_info,&metrics); if (status == False) ThrowReaderException(TypeError,UnableToGetTypeMetrics,image); (void) strlcpy(filename,image_info->filename,MaxTextExtent); if (draw_info->text != '\0') *draw_info->text='\0'; for (offset=2*page.y; p != (char *) NULL; ) { /* Annotate image with text. */ (void) ConcatenateString(&draw_info->text,text); (void) ConcatenateString(&draw_info->text,"\\n"); offset+=(long) (metrics.ascent-metrics.descent); if (image->previous == (Image *) NULL) if (QuantumTick(offset,image->rows)) if (!MagickMonitorFormatted(offset,image->rows,&image->exception, LoadImageText,image->filename, image->columns,image->rows)) break; p=ReadBlobString(image,text); if ((offset < (long) image->rows) && (p != (char *) NULL)) continue; if (texture != (Image *) NULL) { MonitorHandler handler; handler=SetMonitorHandler((MonitorHandler) NULL); (void) TextureImage(image,texture); (void) SetMonitorHandler(handler); } (void) AnnotateImage(image,draw_info); if (p == (char *) NULL) break; /* Page is full-- allocate next image structure. */ *draw_info->text='\0'; offset=2*page.y; AllocateNextImage(image_info,image); if (image->next == (Image *) NULL) { DestroyImageList(image); return((Image *) NULL); } image->next->columns=image->columns; image->next->rows=image->rows; image=SyncNextImageInList(image); (void) strlcpy(image->filename,filename,MaxTextExtent); (void) SetImage(image,OpaqueOpacity); if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),exception, LoadImagesText,image->filename)) break; } if (texture != (Image *) NULL) { MonitorHandler handler; handler=SetMonitorHandler((MonitorHandler) NULL); (void) TextureImage(image,texture); (void) SetMonitorHandler(handler); } (void) AnnotateImage(image,draw_info); if (texture != (Image *) NULL) DestroyImage(texture); DestroyDrawInfo(draw_info); while (image->previous != (Image *) NULL) image=image->previous; TXT_FINISH: CloseBlob(image); return(image); }