Lines Matching refs:image

151 static MagickBooleanType DecodeImage(Image *image,  in DecodeImage()  argument
181 assert(image != (Image *) NULL); in DecodeImage()
182 assert(image->signature == MagickCoreSignature); in DecodeImage()
183 if (image->debug != MagickFalse) in DecodeImage()
184 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); in DecodeImage()
191 for (y=0; y < (ssize_t) image->rows; ) in DecodeImage()
198 count=ReadBlobByte(image); in DecodeImage()
207 byte=ReadBlobByte(image); in DecodeImage()
228 count=ReadBlobByte(image); in DecodeImage()
242 p=pixels+y*image->columns; in DecodeImage()
250 x+=ReadBlobByte(image); in DecodeImage()
251 y+=ReadBlobByte(image); in DecodeImage()
252 p=pixels+y*image->columns+x; in DecodeImage()
264 byte=ReadBlobByte(image); in DecodeImage()
274 byte=ReadBlobByte(image); in DecodeImage()
288 if (ReadBlobByte(image) == EOF) in DecodeImage()
293 if (ReadBlobByte(image) == EOF) in DecodeImage()
299 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, in DecodeImage()
300 image->rows); in DecodeImage()
304 (void) ReadBlobByte(image); /* end of line */ in DecodeImage()
305 (void) ReadBlobByte(image); in DecodeImage()
306 return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue); in DecodeImage()
341 static size_t EncodeImage(Image *image,const size_t bytes_per_line, in EncodeImage() argument
360 assert(image != (Image *) NULL); in EncodeImage()
361 assert(image->signature == MagickCoreSignature); in EncodeImage()
362 if (image->debug != MagickFalse) in EncodeImage()
363 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); in EncodeImage()
369 for (y=0; y < (ssize_t) image->rows; y++) in EncodeImage()
388 if (SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,image->rows) == MagickFalse) in EncodeImage()
465 *image; in ReadDIBImage() local
511 image=AcquireImage(image_info,exception); in ReadDIBImage()
512 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); in ReadDIBImage()
515 image=DestroyImageList(image); in ReadDIBImage()
522 dib_info.size=ReadBlobLSBLong(image); in ReadDIBImage()
528 dib_info.width=ReadBlobLSBSignedLong(image); in ReadDIBImage()
529 dib_info.height=ReadBlobLSBSignedLong(image); in ReadDIBImage()
530 dib_info.planes=ReadBlobLSBShort(image); in ReadDIBImage()
531 dib_info.bits_per_pixel=ReadBlobLSBShort(image); in ReadDIBImage()
534 dib_info.compression=ReadBlobLSBLong(image); in ReadDIBImage()
535 dib_info.image_size=ReadBlobLSBLong(image); in ReadDIBImage()
536 dib_info.x_pixels=ReadBlobLSBLong(image); in ReadDIBImage()
537 dib_info.y_pixels=ReadBlobLSBLong(image); in ReadDIBImage()
538 dib_info.number_colors=ReadBlobLSBLong(image); in ReadDIBImage()
539 dib_info.colors_important=ReadBlobLSBLong(image); in ReadDIBImage()
547 dib_info.red_mask=(unsigned short) ReadBlobLSBLong(image); in ReadDIBImage()
548 dib_info.green_mask=(unsigned short) ReadBlobLSBLong(image); in ReadDIBImage()
549 dib_info.blue_mask=(unsigned short) ReadBlobLSBLong(image); in ReadDIBImage()
551 if (EOFBlob(image) != MagickFalse) in ReadDIBImage()
586 image->columns=(size_t) MagickAbsoluteValue((ssize_t) dib_info.width); in ReadDIBImage()
587 image->rows=(size_t) MagickAbsoluteValue((ssize_t) dib_info.height); in ReadDIBImage()
588 image->depth=8; in ReadDIBImage()
589 image->alpha_trait=dib_info.bits_per_pixel == 32 ? BlendPixelTrait : in ReadDIBImage()
595 if ((dib_info.image_size != 0U) && (dib_info.image_size > GetBlobSize(image))) in ReadDIBImage()
602 image->storage_class=PseudoClass; in ReadDIBImage()
603 image->colors=dib_info.number_colors; in ReadDIBImage()
605 if (image->colors == 0) in ReadDIBImage()
606 image->colors=one << dib_info.bits_per_pixel; in ReadDIBImage()
618 if ((geometry.width != 0) && (geometry.width < image->columns)) in ReadDIBImage()
619 image->columns=geometry.width; in ReadDIBImage()
621 if ((geometry.height != 0) && (geometry.height < image->rows)) in ReadDIBImage()
622 image->rows=geometry.height; in ReadDIBImage()
624 status=SetImageExtent(image,image->columns,image->rows,exception); in ReadDIBImage()
626 return(DestroyImageList(image)); in ReadDIBImage()
627 if (image->storage_class == PseudoClass) in ReadDIBImage()
638 if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) in ReadDIBImage()
640 length=(size_t) image->colors; in ReadDIBImage()
646 count=ReadBlob(image,packet_size*image->colors,dib_colormap); in ReadDIBImage()
647 if (count != (ssize_t) (packet_size*image->colors)) in ReadDIBImage()
653 for (i=0; i < (ssize_t) image->colors; i++) in ReadDIBImage()
655 image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum(*p++); in ReadDIBImage()
656 image->colormap[i].green=(MagickRealType) ScaleCharToQuantum(*p++); in ReadDIBImage()
657 image->colormap[i].red=(MagickRealType) ScaleCharToQuantum(*p++); in ReadDIBImage()
668 bytes_per_line=4*((image->columns*dib_info.bits_per_pixel+31)/32); in ReadDIBImage()
669 length=bytes_per_line*image->rows; in ReadDIBImage()
670 if ((MagickSizeType) length > (256*GetBlobSize(image))) in ReadDIBImage()
672 pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line, in ReadDIBImage()
673 image->columns+256UL)*sizeof(*pixels)); in ReadDIBImage()
680 count=ReadBlob(image,length,pixels); in ReadDIBImage()
692 status=DecodeImage(image,dib_info.compression ? MagickTrue : MagickFalse, in ReadDIBImage()
693 pixels,image->columns*image->rows); in ReadDIBImage()
704 image->units=PixelsPerCentimeterResolution; in ReadDIBImage()
705 image->resolution.x=(double) dib_info.x_pixels/100.0; in ReadDIBImage()
706 image->resolution.y=(double) dib_info.y_pixels/100.0; in ReadDIBImage()
717 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadDIBImage()
719 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadDIBImage()
720 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadDIBImage()
723 for (x=0; x < ((ssize_t) image->columns-7); x+=8) in ReadDIBImage()
728 SetPixelIndex(image,index,q); in ReadDIBImage()
729 q+=GetPixelChannels(image); in ReadDIBImage()
733 if ((image->columns % 8) != 0) in ReadDIBImage()
735 for (bit=0; bit < (ssize_t) (image->columns % 8); bit++) in ReadDIBImage()
738 SetPixelIndex(image,index,q); in ReadDIBImage()
739 q+=GetPixelChannels(image); in ReadDIBImage()
743 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadDIBImage()
745 if (image->previous == (Image *) NULL) in ReadDIBImage()
747 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadDIBImage()
748 image->rows-y-1,image->rows); in ReadDIBImage()
753 (void) SyncImage(image,exception); in ReadDIBImage()
761 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadDIBImage()
763 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadDIBImage()
764 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadDIBImage()
767 for (x=0; x < ((ssize_t) image->columns-1); x+=2) in ReadDIBImage()
769 index=(Quantum) ConstrainColormapIndex(image,(ssize_t) (*p >> 4) & in ReadDIBImage()
771 SetPixelIndex(image,index,q); in ReadDIBImage()
772 q+=GetPixelChannels(image); in ReadDIBImage()
773 index=(Quantum) ConstrainColormapIndex(image,(ssize_t) *p & 0xf, in ReadDIBImage()
775 SetPixelIndex(image,index,q); in ReadDIBImage()
777 q+=GetPixelChannels(image); in ReadDIBImage()
779 if ((image->columns % 2) != 0) in ReadDIBImage()
781 index=(Quantum) ConstrainColormapIndex(image,(ssize_t) (*p >> 4) & in ReadDIBImage()
783 SetPixelIndex(image,index,q); in ReadDIBImage()
784 q+=GetPixelChannels(image); in ReadDIBImage()
787 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadDIBImage()
789 if (image->previous == (Image *) NULL) in ReadDIBImage()
791 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadDIBImage()
792 image->rows-y-1,image->rows); in ReadDIBImage()
797 (void) SyncImage(image,exception); in ReadDIBImage()
807 bytes_per_line=image->columns; in ReadDIBImage()
808 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadDIBImage()
810 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadDIBImage()
811 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadDIBImage()
814 for (x=0; x < (ssize_t) image->columns; x++) in ReadDIBImage()
816 index=(Quantum) ConstrainColormapIndex(image,(ssize_t) *p,exception); in ReadDIBImage()
817 SetPixelIndex(image,index,q); in ReadDIBImage()
819 q+=GetPixelChannels(image); in ReadDIBImage()
821 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadDIBImage()
823 if (image->previous == (Image *) NULL) in ReadDIBImage()
825 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadDIBImage()
826 image->rows-y-1,image->rows); in ReadDIBImage()
831 (void) SyncImage(image,exception); in ReadDIBImage()
842 image->storage_class=DirectClass; in ReadDIBImage()
844 bytes_per_line=2*image->columns; in ReadDIBImage()
845 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadDIBImage()
847 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadDIBImage()
848 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadDIBImage()
851 for (x=0; x < (ssize_t) image->columns; x++) in ReadDIBImage()
857 SetPixelRed(image,ScaleCharToQuantum(ScaleColor5to8( in ReadDIBImage()
859 SetPixelGreen(image,ScaleCharToQuantum(ScaleColor5to8( in ReadDIBImage()
861 SetPixelBlue(image,ScaleCharToQuantum(ScaleColor5to8( in ReadDIBImage()
866 SetPixelRed(image,ScaleCharToQuantum(ScaleColor5to8( in ReadDIBImage()
868 SetPixelGreen(image,ScaleCharToQuantum(ScaleColor6to8( in ReadDIBImage()
870 SetPixelBlue(image,ScaleCharToQuantum(ScaleColor5to8( in ReadDIBImage()
873 q+=GetPixelChannels(image); in ReadDIBImage()
875 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadDIBImage()
877 if (image->previous == (Image *) NULL) in ReadDIBImage()
879 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadDIBImage()
880 image->rows-y-1,image->rows); in ReadDIBImage()
893 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadDIBImage()
895 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadDIBImage()
896 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadDIBImage()
899 for (x=0; x < (ssize_t) image->columns; x++) in ReadDIBImage()
901 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); in ReadDIBImage()
902 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); in ReadDIBImage()
903 SetPixelRed(image,ScaleCharToQuantum(*p++),q); in ReadDIBImage()
904 if (image->alpha_trait != UndefinedPixelTrait) in ReadDIBImage()
905 SetPixelAlpha(image,ScaleCharToQuantum(*p++),q); in ReadDIBImage()
906 q+=GetPixelChannels(image); in ReadDIBImage()
908 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadDIBImage()
910 if (image->previous == (Image *) NULL) in ReadDIBImage()
912 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadDIBImage()
913 image->rows-y-1,image->rows); in ReadDIBImage()
933 image->storage_class=DirectClass; in ReadDIBImage()
934 image->alpha_trait=BlendPixelTrait; in ReadDIBImage()
935 for (y=0; y < (ssize_t) image->rows; y++) in ReadDIBImage()
943 q=GetAuthenticPixels(image,0,y,image->columns,1,exception); in ReadDIBImage()
946 for (x=0; x < ((ssize_t) image->columns-7); x+=8) in ReadDIBImage()
948 c=ReadBlobByte(image); in ReadDIBImage()
950 SetPixelAlpha(image,c & (0x80 >> bit) ? TransparentAlpha : in ReadDIBImage()
951 OpaqueAlpha,q+x*GetPixelChannels(image)+bit); in ReadDIBImage()
953 if ((image->columns % 8) != 0) in ReadDIBImage()
955 c=ReadBlobByte(image); in ReadDIBImage()
956 for (bit=0; bit < (ssize_t) (image->columns % 8); bit++) in ReadDIBImage()
957 SetPixelAlpha(image,c & (0x80 >> bit) ? TransparentAlpha : in ReadDIBImage()
958 OpaqueAlpha,q+x*GetPixelChannels(image)+bit); in ReadDIBImage()
960 if (image->columns % 32) in ReadDIBImage()
961 for (x=0; x < (ssize_t) ((32-(image->columns % 32))/8); x++) in ReadDIBImage()
962 c=ReadBlobByte(image); in ReadDIBImage()
963 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadDIBImage()
967 if (EOFBlob(image) != MagickFalse) in ReadDIBImage()
969 image->filename); in ReadDIBImage()
978 flipped_image=FlipImage(image,exception); in ReadDIBImage()
981 DuplicateBlob(flipped_image,image); in ReadDIBImage()
982 image=DestroyImage(image); in ReadDIBImage()
983 image=flipped_image; in ReadDIBImage()
986 (void) CloseBlob(image); in ReadDIBImage()
987 return(GetFirstImageInList(image)); in ReadDIBImage()
1091 static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image, in WriteDIBImage() argument
1125 assert(image != (Image *) NULL); in WriteDIBImage()
1126 assert(image->signature == MagickCoreSignature); in WriteDIBImage()
1127 if (image->debug != MagickFalse) in WriteDIBImage()
1128 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); in WriteDIBImage()
1131 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); in WriteDIBImage()
1137 (void) TransformImageColorspace(image,sRGBColorspace,exception); in WriteDIBImage()
1138 if (image->storage_class == DirectClass) in WriteDIBImage()
1144 dib_info.bits_per_pixel=(unsigned short) (image->alpha_trait ? 32 : 24); in WriteDIBImage()
1154 if (SetImageMonochrome(image,exception) != MagickFalse) in WriteDIBImage()
1159 bytes_per_line=4*((image->columns*dib_info.bits_per_pixel+31)/32); in WriteDIBImage()
1161 dib_info.width=(int) image->columns; in WriteDIBImage()
1162 dib_info.height=(int) image->rows; in WriteDIBImage()
1166 dib_info.image_size=(unsigned int) (bytes_per_line*image->rows); in WriteDIBImage()
1169 switch (image->units) in WriteDIBImage()
1174 dib_info.x_pixels=(unsigned int) (100.0*image->resolution.x/2.54); in WriteDIBImage()
1175 dib_info.y_pixels=(unsigned int) (100.0*image->resolution.y/2.54); in WriteDIBImage()
1180 dib_info.x_pixels=(unsigned int) (100.0*image->resolution.x); in WriteDIBImage()
1181 dib_info.y_pixels=(unsigned int) (100.0*image->resolution.y); in WriteDIBImage()
1189 pixels=(unsigned char *) AcquireQuantumMemory(image->rows,MagickMax( in WriteDIBImage()
1190 bytes_per_line,image->columns+256UL)*sizeof(*pixels)); in WriteDIBImage()
1205 for (y=0; y < (ssize_t) image->rows; y++) in WriteDIBImage()
1207 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteDIBImage()
1210 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteDIBImage()
1213 for (x=0; x < (ssize_t) image->columns; x++) in WriteDIBImage()
1216 byte|=GetPixelIndex(image,p) != 0 ? 0x01 : 0x00; in WriteDIBImage()
1224 p+=GetPixelChannels(image); in WriteDIBImage()
1231 for (x=(ssize_t) (image->columns+7)/8; x < (ssize_t) bytes_per_line; x++) in WriteDIBImage()
1233 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteDIBImage()
1234 image->rows); in WriteDIBImage()
1245 for (y=0; y < (ssize_t) image->rows; y++) in WriteDIBImage()
1247 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteDIBImage()
1250 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteDIBImage()
1251 for (x=0; x < (ssize_t) image->columns; x++) in WriteDIBImage()
1253 *q++=(unsigned char) GetPixelIndex(image,p); in WriteDIBImage()
1254 p+=GetPixelChannels(image); in WriteDIBImage()
1258 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteDIBImage()
1259 image->rows); in WriteDIBImage()
1272 for (y=0; y < (ssize_t) image->rows; y++) in WriteDIBImage()
1274 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteDIBImage()
1277 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteDIBImage()
1278 for (x=0; x < (ssize_t) image->columns; x++) in WriteDIBImage()
1281 ScaleQuantumToChar(GetPixelRed(image,p))) << 11) | (ScaleColor8to6( in WriteDIBImage()
1282 (unsigned char) ScaleQuantumToChar(GetPixelGreen(image,p))) << 5) | in WriteDIBImage()
1284 GetPixelBlue(image,p)) << 0))); in WriteDIBImage()
1287 p+=GetPixelChannels(image); in WriteDIBImage()
1289 for (x=(ssize_t) (2*image->columns); x < (ssize_t) bytes_per_line; x++) in WriteDIBImage()
1291 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteDIBImage()
1292 image->rows); in WriteDIBImage()
1304 for (y=0; y < (ssize_t) image->rows; y++) in WriteDIBImage()
1306 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteDIBImage()
1309 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteDIBImage()
1310 for (x=0; x < (ssize_t) image->columns; x++) in WriteDIBImage()
1312 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); in WriteDIBImage()
1313 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); in WriteDIBImage()
1314 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); in WriteDIBImage()
1315 if (image->alpha_trait != UndefinedPixelTrait) in WriteDIBImage()
1316 *q++=ScaleQuantumToChar(GetPixelAlpha(image,p)); in WriteDIBImage()
1317 p+=GetPixelChannels(image); in WriteDIBImage()
1320 for (x=(ssize_t) (3*image->columns); x < (ssize_t) bytes_per_line; x++) in WriteDIBImage()
1322 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteDIBImage()
1323 image->rows); in WriteDIBImage()
1341 (image->rows+2UL)*sizeof(*dib_data)); in WriteDIBImage()
1347 dib_info.image_size=(unsigned int) EncodeImage(image,bytes_per_line, in WriteDIBImage()
1356 (void) WriteBlobLSBLong(image,dib_info.size); in WriteDIBImage()
1357 (void) WriteBlobLSBLong(image,(unsigned int) dib_info.width); in WriteDIBImage()
1358 (void) WriteBlobLSBLong(image,(unsigned int) dib_info.height); in WriteDIBImage()
1359 (void) WriteBlobLSBShort(image,(unsigned short) dib_info.planes); in WriteDIBImage()
1360 (void) WriteBlobLSBShort(image,dib_info.bits_per_pixel); in WriteDIBImage()
1361 (void) WriteBlobLSBLong(image,dib_info.compression); in WriteDIBImage()
1362 (void) WriteBlobLSBLong(image,dib_info.image_size); in WriteDIBImage()
1363 (void) WriteBlobLSBLong(image,dib_info.x_pixels); in WriteDIBImage()
1364 (void) WriteBlobLSBLong(image,dib_info.y_pixels); in WriteDIBImage()
1365 (void) WriteBlobLSBLong(image,dib_info.number_colors); in WriteDIBImage()
1366 (void) WriteBlobLSBLong(image,dib_info.colors_important); in WriteDIBImage()
1367 if (image->storage_class == PseudoClass) in WriteDIBImage()
1385 for (i=0; i < (ssize_t) MagickMin(image->colors,dib_info.number_colors); i++) in WriteDIBImage()
1387 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].blue)); in WriteDIBImage()
1388 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].green)); in WriteDIBImage()
1389 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].red)); in WriteDIBImage()
1399 (void) WriteBlob(image,(size_t) (4*(1 << dib_info.bits_per_pixel)), in WriteDIBImage()
1407 (void) WriteBlobLSBLong(image,0xf800); in WriteDIBImage()
1408 (void) WriteBlobLSBLong(image,0x07e0); in WriteDIBImage()
1409 (void) WriteBlobLSBLong(image,0x001f); in WriteDIBImage()
1412 (void) WriteBlob(image,dib_info.image_size,pixels); in WriteDIBImage()
1414 (void) CloseBlob(image); in WriteDIBImage()