Lines Matching refs:image

202 static MagickBooleanType DecodeImage(Image *image,const size_t compression,  in DecodeImage()  argument
220 assert(image != (Image *) NULL); in DecodeImage()
221 assert(image->signature == MagickCoreSignature); in DecodeImage()
222 if (image->debug != MagickFalse) in DecodeImage()
223 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); in DecodeImage()
230 for (y=0; y < (ssize_t) image->rows; ) in DecodeImage()
237 count=ReadBlobByte(image); in DecodeImage()
246 byte=ReadBlobByte(image); in DecodeImage()
267 count=ReadBlobByte(image); in DecodeImage()
281 p=pixels+y*image->columns; in DecodeImage()
289 x+=ReadBlobByte(image); in DecodeImage()
290 y+=ReadBlobByte(image); in DecodeImage()
291 p=pixels+y*image->columns+x; in DecodeImage()
303 byte=ReadBlobByte(image); in DecodeImage()
313 byte=ReadBlobByte(image); in DecodeImage()
327 if (ReadBlobByte(image) == EOF) in DecodeImage()
332 if (ReadBlobByte(image) == EOF) in DecodeImage()
338 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, in DecodeImage()
339 image->rows); in DecodeImage()
343 (void) ReadBlobByte(image); /* end of line */ in DecodeImage()
344 (void) ReadBlobByte(image); in DecodeImage()
345 return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue); in DecodeImage()
380 static size_t EncodeImage(Image *image,const size_t bytes_per_line, in EncodeImage() argument
402 assert(image != (Image *) NULL); in EncodeImage()
403 assert(image->signature == MagickCoreSignature); in EncodeImage()
404 if (image->debug != MagickFalse) in EncodeImage()
405 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); in EncodeImage()
411 for (y=0; y < (ssize_t) image->rows; y++) in EncodeImage()
430 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in EncodeImage()
431 image->rows); in EncodeImage()
516 *image; in ReadBMPImage() local
572 image=AcquireImage(image_info,exception); in ReadBMPImage()
573 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); in ReadBMPImage()
576 image=DestroyImageList(image); in ReadBMPImage()
586 count=ReadBlob(image,2,magick); in ReadBMPImage()
600 start_position=TellBlob(image)-2; in ReadBMPImage()
604 bmp_info.file_size=ReadBlobLSBLong(image); in ReadBMPImage()
605 bmp_info.ba_offset=ReadBlobLSBLong(image); in ReadBMPImage()
606 bmp_info.offset_bits=ReadBlobLSBLong(image); in ReadBMPImage()
607 count=ReadBlob(image,2,magick); in ReadBMPImage()
611 if (image->debug != MagickFalse) in ReadBMPImage()
617 bmp_info.file_size=ReadBlobLSBLong(image); in ReadBMPImage()
618 (void) ReadBlobLSBLong(image); in ReadBMPImage()
619 bmp_info.offset_bits=ReadBlobLSBLong(image); in ReadBMPImage()
620 bmp_info.size=ReadBlobLSBLong(image); in ReadBMPImage()
621 if (image->debug != MagickFalse) in ReadBMPImage()
631 (void) CopyMagickString(image->magick,"BMP2",MagickPathExtent); in ReadBMPImage()
632 bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image)); in ReadBMPImage()
633 bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image)); in ReadBMPImage()
634 bmp_info.planes=ReadBlobLSBShort(image); in ReadBMPImage()
635 bmp_info.bits_per_pixel=ReadBlobLSBShort(image); in ReadBMPImage()
642 if (image->debug != MagickFalse) in ReadBMPImage()
658 bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image); in ReadBMPImage()
659 bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image); in ReadBMPImage()
660 bmp_info.planes=ReadBlobLSBShort(image); in ReadBMPImage()
661 bmp_info.bits_per_pixel=ReadBlobLSBShort(image); in ReadBMPImage()
662 bmp_info.compression=ReadBlobLSBLong(image); in ReadBMPImage()
663 bmp_info.image_size=ReadBlobLSBLong(image); in ReadBMPImage()
664 bmp_info.x_pixels=ReadBlobLSBLong(image); in ReadBMPImage()
665 bmp_info.y_pixels=ReadBlobLSBLong(image); in ReadBMPImage()
666 bmp_info.number_colors=ReadBlobLSBLong(image); in ReadBMPImage()
667 if ((MagickSizeType) bmp_info.number_colors > GetBlobSize(image)) in ReadBMPImage()
669 bmp_info.colors_important=ReadBlobLSBLong(image); in ReadBMPImage()
670 if (image->debug != MagickFalse) in ReadBMPImage()
726 bmp_info.red_mask=ReadBlobLSBLong(image); in ReadBMPImage()
727 bmp_info.green_mask=ReadBlobLSBLong(image); in ReadBMPImage()
728 bmp_info.blue_mask=ReadBlobLSBLong(image); in ReadBMPImage()
737 bmp_info.alpha_mask=ReadBlobLSBLong(image); in ReadBMPImage()
738 bmp_info.colorspace=ReadBlobLSBSignedLong(image); in ReadBMPImage()
743 bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
744 bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
745 bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
746 bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
747 bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
748 bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
749 bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
750 bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
751 bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
758 image->chromaticity.red_primary.x=bmp_info.red_primary.x; in ReadBMPImage()
759 image->chromaticity.red_primary.y=bmp_info.red_primary.y; in ReadBMPImage()
766 image->chromaticity.green_primary.x=bmp_info.green_primary.x; in ReadBMPImage()
767 image->chromaticity.green_primary.y=bmp_info.green_primary.y; in ReadBMPImage()
774 image->chromaticity.blue_primary.x=bmp_info.blue_primary.x; in ReadBMPImage()
775 image->chromaticity.blue_primary.y=bmp_info.blue_primary.y; in ReadBMPImage()
780 bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)/0x10000; in ReadBMPImage()
781 bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)/0x10000; in ReadBMPImage()
782 bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)/0x10000; in ReadBMPImage()
786 image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+ in ReadBMPImage()
790 (void) CopyMagickString(image->magick,"BMP3",MagickPathExtent); in ReadBMPImage()
800 intent=ReadBlobLSBLong(image); in ReadBMPImage()
805 image->rendering_intent=SaturationIntent; in ReadBMPImage()
810 image->rendering_intent=RelativeIntent; in ReadBMPImage()
815 image->rendering_intent=PerceptualIntent; in ReadBMPImage()
820 image->rendering_intent=AbsoluteIntent; in ReadBMPImage()
824 profile_data=(MagickOffsetType)ReadBlobLSBLong(image); in ReadBMPImage()
825 profile_size=(MagickOffsetType)ReadBlobLSBLong(image); in ReadBMPImage()
826 (void) ReadBlobLSBLong(image); /* Reserved byte */ in ReadBMPImage()
829 if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image)) in ReadBMPImage()
831 "LengthAndFilesizeDoNotMatch","`%s'",image->filename); in ReadBMPImage()
833 if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image)) in ReadBMPImage()
836 image->filename); in ReadBMPImage()
859 image->compression=NoCompression; in ReadBMPImage()
863 image->compression=RLECompression; in ReadBMPImage()
874 image->columns=(size_t) MagickAbsoluteValue(bmp_info.width); in ReadBMPImage()
875 image->rows=(size_t) MagickAbsoluteValue(bmp_info.height); in ReadBMPImage()
876 image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8; in ReadBMPImage()
877 image->alpha_trait=((bmp_info.alpha_mask != 0) && in ReadBMPImage()
885 image->storage_class=PseudoClass; in ReadBMPImage()
886 image->colors=bmp_info.number_colors; in ReadBMPImage()
888 if (image->colors == 0) in ReadBMPImage()
889 image->colors=one << bmp_info.bits_per_pixel; in ReadBMPImage()
891 image->resolution.x=(double) bmp_info.x_pixels/100.0; in ReadBMPImage()
892 image->resolution.y=(double) bmp_info.y_pixels/100.0; in ReadBMPImage()
893 image->units=PixelsPerCentimeterResolution; in ReadBMPImage()
895 if (image->scene >= (image_info->scene+image_info->number_scenes-1)) in ReadBMPImage()
897 status=SetImageExtent(image,image->columns,image->rows,exception); in ReadBMPImage()
899 return(DestroyImageList(image)); in ReadBMPImage()
900 if (image->storage_class == PseudoClass) in ReadBMPImage()
911 if (image->debug != MagickFalse) in ReadBMPImage()
913 " Reading colormap of %.20g colors",(double) image->colors); in ReadBMPImage()
914 if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) in ReadBMPImage()
917 image->colors,4*sizeof(*bmp_colormap)); in ReadBMPImage()
924 offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET); in ReadBMPImage()
930 count=ReadBlob(image,packet_size*image->colors,bmp_colormap); in ReadBMPImage()
931 if (count != (ssize_t) (packet_size*image->colors)) in ReadBMPImage()
938 for (i=0; i < (ssize_t) image->colors; i++) in ReadBMPImage()
940 image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum(*p++); in ReadBMPImage()
941 image->colormap[i].green=(MagickRealType) ScaleCharToQuantum(*p++); in ReadBMPImage()
942 image->colormap[i].red=(MagickRealType) ScaleCharToQuantum(*p++); in ReadBMPImage()
954 offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET); in ReadBMPImage()
959 bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32); in ReadBMPImage()
960 length=(size_t) bytes_per_line*image->rows; in ReadBMPImage()
961 if ((MagickSizeType) (length/256) > GetBlobSize(image)) in ReadBMPImage()
966 pixel_info=AcquireVirtualMemory(image->rows, in ReadBMPImage()
967 MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); in ReadBMPImage()
971 if (image->debug != MagickFalse) in ReadBMPImage()
974 count=ReadBlob(image,length,pixels); in ReadBMPImage()
987 pixel_info=AcquireVirtualMemory(image->rows, in ReadBMPImage()
988 MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); in ReadBMPImage()
992 status=DecodeImage(image,bmp_info.compression,pixels, in ReadBMPImage()
993 image->columns*image->rows); in ReadBMPImage()
1013 if ((image->alpha_trait == UndefinedPixelTrait) && in ReadBMPImage()
1016 bytes_per_line=4*(image->columns); in ReadBMPImage()
1017 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1019 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1020 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1024 image->alpha_trait=BlendPixelTrait; in ReadBMPImage()
1032 bmp_info.alpha_mask=image->alpha_trait != UndefinedPixelTrait ? in ReadBMPImage()
1125 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1127 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1128 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1131 for (x=0; x < ((ssize_t) image->columns-7); x+=8) in ReadBMPImage()
1136 SetPixelIndex(image,index,q); in ReadBMPImage()
1137 q+=GetPixelChannels(image); in ReadBMPImage()
1141 if ((image->columns % 8) != 0) in ReadBMPImage()
1143 for (bit=0; bit < (image->columns % 8); bit++) in ReadBMPImage()
1146 SetPixelIndex(image,index,q); in ReadBMPImage()
1147 q+=GetPixelChannels(image); in ReadBMPImage()
1151 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1153 if (image->previous == (Image *) NULL) in ReadBMPImage()
1155 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1156 (image->rows-y),image->rows); in ReadBMPImage()
1161 (void) SyncImage(image,exception); in ReadBMPImage()
1169 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1171 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1172 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1175 for (x=0; x < ((ssize_t) image->columns-1); x+=2) in ReadBMPImage()
1177 ValidateColormapValue(image,(ssize_t) ((*p >> 4) & 0x0f),&index, in ReadBMPImage()
1179 SetPixelIndex(image,index,q); in ReadBMPImage()
1180 q+=GetPixelChannels(image); in ReadBMPImage()
1181 ValidateColormapValue(image,(ssize_t) (*p & 0x0f),&index,exception); in ReadBMPImage()
1182 SetPixelIndex(image,index,q); in ReadBMPImage()
1183 q+=GetPixelChannels(image); in ReadBMPImage()
1186 if ((image->columns % 2) != 0) in ReadBMPImage()
1188 ValidateColormapValue(image,(ssize_t) ((*p >> 4) & 0xf),&index, in ReadBMPImage()
1190 SetPixelIndex(image,index,q); in ReadBMPImage()
1191 q+=GetPixelChannels(image); in ReadBMPImage()
1195 if (x < (ssize_t) image->columns) in ReadBMPImage()
1197 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1199 if (image->previous == (Image *) NULL) in ReadBMPImage()
1201 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1202 (image->rows-y),image->rows); in ReadBMPImage()
1207 (void) SyncImage(image,exception); in ReadBMPImage()
1217 bytes_per_line=image->columns; in ReadBMPImage()
1218 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1220 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1221 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1224 for (x=(ssize_t) image->columns; x != 0; --x) in ReadBMPImage()
1226 ValidateColormapValue(image,(ssize_t) *p++,&index,exception); in ReadBMPImage()
1227 SetPixelIndex(image,index,q); in ReadBMPImage()
1228 q+=GetPixelChannels(image); in ReadBMPImage()
1230 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1232 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1233 if (image->previous == (Image *) NULL) in ReadBMPImage()
1235 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1236 (image->rows-y),image->rows); in ReadBMPImage()
1241 (void) SyncImage(image,exception); in ReadBMPImage()
1260 bytes_per_line=2*(image->columns+image->columns % 2); in ReadBMPImage()
1261 image->storage_class=DirectClass; in ReadBMPImage()
1262 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1264 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1265 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1268 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1289 SetPixelRed(image,ScaleShortToQuantum((unsigned short) red),q); in ReadBMPImage()
1290 SetPixelGreen(image,ScaleShortToQuantum((unsigned short) green),q); in ReadBMPImage()
1291 SetPixelBlue(image,ScaleShortToQuantum((unsigned short) blue),q); in ReadBMPImage()
1292 SetPixelAlpha(image,OpaqueAlpha,q); in ReadBMPImage()
1293 if (image->alpha_trait != UndefinedPixelTrait) in ReadBMPImage()
1298 SetPixelAlpha(image,ScaleShortToQuantum( in ReadBMPImage()
1301 q+=GetPixelChannels(image); in ReadBMPImage()
1303 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1305 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1306 if (image->previous == (Image *) NULL) in ReadBMPImage()
1308 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1309 (image->rows-y),image->rows); in ReadBMPImage()
1321 bytes_per_line=4*((image->columns*24+31)/32); in ReadBMPImage()
1322 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1324 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1325 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1328 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1330 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); in ReadBMPImage()
1331 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); in ReadBMPImage()
1332 SetPixelRed(image,ScaleCharToQuantum(*p++),q); in ReadBMPImage()
1333 SetPixelAlpha(image,OpaqueAlpha,q); in ReadBMPImage()
1334 q+=GetPixelChannels(image); in ReadBMPImage()
1336 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1338 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1339 if (image->previous == (Image *) NULL) in ReadBMPImage()
1341 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1342 (image->rows-y),image->rows); in ReadBMPImage()
1361 bytes_per_line=4*(image->columns); in ReadBMPImage()
1362 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1368 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1369 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1372 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1387 SetPixelRed(image,ScaleShortToQuantum((unsigned short) red),q); in ReadBMPImage()
1388 SetPixelGreen(image,ScaleShortToQuantum((unsigned short) green),q); in ReadBMPImage()
1389 SetPixelBlue(image,ScaleShortToQuantum((unsigned short) blue),q); in ReadBMPImage()
1390 SetPixelAlpha(image,OpaqueAlpha,q); in ReadBMPImage()
1391 if (image->alpha_trait != UndefinedPixelTrait) in ReadBMPImage()
1396 SetPixelAlpha(image,ScaleShortToQuantum( in ReadBMPImage()
1399 q+=GetPixelChannels(image); in ReadBMPImage()
1401 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1403 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1404 if (image->previous == (Image *) NULL) in ReadBMPImage()
1406 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1407 (image->rows-y),image->rows); in ReadBMPImage()
1423 if (EOFBlob(image) != MagickFalse) in ReadBMPImage()
1426 image->filename); in ReadBMPImage()
1437 flipped_image=FlipImage(image,exception); in ReadBMPImage()
1440 DuplicateBlob(flipped_image,image); in ReadBMPImage()
1441 ReplaceImageInList(&image, flipped_image); in ReadBMPImage()
1442 image=flipped_image; in ReadBMPImage()
1458 if ((offset < TellBlob(image)) || in ReadBMPImage()
1459 (SeekBlob(image,offset,SEEK_SET) != offset) || in ReadBMPImage()
1460 (GetBlobSize(image) < (MagickSizeType) (offset+profile_size))) in ReadBMPImage()
1466 if (ReadBlob(image,(size_t) profile_size,datum) == (ssize_t) profile_size) in ReadBMPImage()
1480 if (image->debug != MagickFalse) in ReadBMPImage()
1483 (void) SetImageProfile(image,"icc",profile,exception); in ReadBMPImage()
1491 if (image->scene >= (image_info->scene+image_info->number_scenes-1)) in ReadBMPImage()
1495 if ((offset < TellBlob(image)) || in ReadBMPImage()
1496 (SeekBlob(image,offset,SEEK_SET) != offset)) in ReadBMPImage()
1499 count=ReadBlob(image,2,magick); in ReadBMPImage()
1505 AcquireNextImage(image_info,image,exception); in ReadBMPImage()
1506 if (GetNextImageInList(image) == (Image *) NULL) in ReadBMPImage()
1511 image=SyncNextImageInList(image); in ReadBMPImage()
1512 status=SetImageProgress(image,LoadImagesTag,TellBlob(image), in ReadBMPImage()
1513 GetBlobSize(image)); in ReadBMPImage()
1518 (void) CloseBlob(image); in ReadBMPImage()
1520 return(DestroyImageList(image)); in ReadBMPImage()
1521 return(GetFirstImageInList(image)); in ReadBMPImage()
1631 static MagickBooleanType WriteBMPImage(const ImageInfo *image_info,Image *image, in WriteBMPImage() argument
1688 assert(image != (Image *) NULL); in WriteBMPImage()
1689 assert(image->signature == MagickCoreSignature); in WriteBMPImage()
1690 if (image->debug != MagickFalse) in WriteBMPImage()
1691 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); in WriteBMPImage()
1694 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); in WriteBMPImage()
1716 imageListLength=GetImageListLength(image); in WriteBMPImage()
1722 if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) in WriteBMPImage()
1723 (void) TransformImageColorspace(image,sRGBColorspace,exception); in WriteBMPImage()
1735 if ((image->storage_class == PseudoClass) && (image->colors > 256)) in WriteBMPImage()
1736 (void) SetImageStorageClass(image,DirectClass,exception); in WriteBMPImage()
1737 if (image->storage_class != DirectClass) in WriteBMPImage()
1743 if (image->colors <= 2) in WriteBMPImage()
1746 if (image->colors <= 16) in WriteBMPImage()
1749 if (image->colors <= 256) in WriteBMPImage()
1754 if (image->alpha_trait != UndefinedPixelTrait) in WriteBMPImage()
1755 (void) SetImageStorageClass(image,DirectClass,exception); in WriteBMPImage()
1757 if ((size_t) bmp_info.number_colors < image->colors) in WriteBMPImage()
1758 (void) SetImageStorageClass(image,DirectClass,exception); in WriteBMPImage()
1770 if (image->storage_class == DirectClass) in WriteBMPImage()
1779 if (image->alpha_trait != UndefinedPixelTrait) in WriteBMPImage()
1826 (image->alpha_trait != UndefinedPixelTrait) ? 32 : 24); in WriteBMPImage()
1828 (image->alpha_trait != UndefinedPixelTrait) ? BI_BITFIELDS : BI_RGB); in WriteBMPImage()
1829 if ((type == 3) && (image->alpha_trait != UndefinedPixelTrait)) in WriteBMPImage()
1837 bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32); in WriteBMPImage()
1839 profile=GetImageProfile(image,"icc"); in WriteBMPImage()
1840 have_color_info=(image->rendering_intent != UndefinedIntent) || in WriteBMPImage()
1841 (profile != (StringInfo *) NULL) || (image->gamma != 0.0) ? MagickTrue : in WriteBMPImage()
1846 if ((type == 3) || ((image->alpha_trait == UndefinedPixelTrait) && in WriteBMPImage()
1859 if ((image->rendering_intent != UndefinedIntent) || in WriteBMPImage()
1868 if (((ssize_t) image->columns != (ssize_t) ((signed int) image->columns)) || in WriteBMPImage()
1869 ((ssize_t) image->rows != (ssize_t) ((signed int) image->rows))) in WriteBMPImage()
1871 bmp_info.width=(ssize_t) image->columns; in WriteBMPImage()
1872 bmp_info.height=(ssize_t) image->rows; in WriteBMPImage()
1874 bmp_info.image_size=(unsigned int) (bytes_per_line*image->rows); in WriteBMPImage()
1878 switch (image->units) in WriteBMPImage()
1883 bmp_info.x_pixels=(unsigned int) (100.0*image->resolution.x/2.54); in WriteBMPImage()
1884 bmp_info.y_pixels=(unsigned int) (100.0*image->resolution.y/2.54); in WriteBMPImage()
1889 bmp_info.x_pixels=(unsigned int) (100.0*image->resolution.x); in WriteBMPImage()
1890 bmp_info.y_pixels=(unsigned int) (100.0*image->resolution.y); in WriteBMPImage()
1898 pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line, in WriteBMPImage()
1899 image->columns+256UL)*sizeof(*pixels)); in WriteBMPImage()
1915 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
1920 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
1923 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
1926 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
1929 byte|=GetPixelIndex(image,p) != 0 ? 0x01 : 0x00; in WriteBMPImage()
1937 p+=GetPixelChannels(image); in WriteBMPImage()
1944 offset=(ssize_t) (image->columns+7)/8; in WriteBMPImage()
1947 if (image->previous == (Image *) NULL) in WriteBMPImage()
1949 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
1950 image->rows); in WriteBMPImage()
1969 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
1971 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
1974 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
1977 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
1980 byte|=((unsigned int) GetPixelIndex(image,p) & 0x0f); in WriteBMPImage()
1988 p+=GetPixelChannels(image); in WriteBMPImage()
1995 offset=(ssize_t) (image->columns+1)/2; in WriteBMPImage()
1998 if (image->previous == (Image *) NULL) in WriteBMPImage()
2000 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2001 image->rows); in WriteBMPImage()
2013 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2015 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2018 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2019 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2021 *q++=(unsigned char) GetPixelIndex(image,p); in WriteBMPImage()
2022 p+=GetPixelChannels(image); in WriteBMPImage()
2026 if (image->previous == (Image *) NULL) in WriteBMPImage()
2028 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2029 image->rows); in WriteBMPImage()
2041 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2043 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2046 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2047 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2056 GetPixelAlpha(image,p),15) << 12); in WriteBMPImage()
2058 GetPixelRed(image,p),15) << 8); in WriteBMPImage()
2060 GetPixelGreen(image,p),15) << 4); in WriteBMPImage()
2062 GetPixelBlue(image,p),15)); in WriteBMPImage()
2067 GetPixelRed(image,p),31) << 11); in WriteBMPImage()
2069 GetPixelGreen(image,p),63) << 5); in WriteBMPImage()
2071 GetPixelBlue(image,p),31)); in WriteBMPImage()
2077 GetPixelAlpha(image,p),1) << 15); in WriteBMPImage()
2079 GetPixelRed(image,p),31) << 10); in WriteBMPImage()
2081 GetPixelGreen(image,p),31) << 5); in WriteBMPImage()
2083 GetPixelBlue(image,p),31)); in WriteBMPImage()
2087 p+=GetPixelChannels(image); in WriteBMPImage()
2089 for (x=2L*(ssize_t) image->columns; x < (ssize_t) bytes_per_line; x++) in WriteBMPImage()
2091 if (image->previous == (Image *) NULL) in WriteBMPImage()
2093 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2094 image->rows); in WriteBMPImage()
2106 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2108 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2111 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2112 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2114 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); in WriteBMPImage()
2115 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); in WriteBMPImage()
2116 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); in WriteBMPImage()
2117 p+=GetPixelChannels(image); in WriteBMPImage()
2119 for (x=3L*(ssize_t) image->columns; x < (ssize_t) bytes_per_line; x++) in WriteBMPImage()
2121 if (image->previous == (Image *) NULL) in WriteBMPImage()
2123 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2124 image->rows); in WriteBMPImage()
2136 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2138 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2141 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2142 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2144 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); in WriteBMPImage()
2145 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); in WriteBMPImage()
2146 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); in WriteBMPImage()
2147 *q++=ScaleQuantumToChar(GetPixelAlpha(image,p)); in WriteBMPImage()
2148 p+=GetPixelChannels(image); in WriteBMPImage()
2150 if (image->previous == (Image *) NULL) in WriteBMPImage()
2152 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2153 image->rows); in WriteBMPImage()
2171 (image->rows+2)*sizeof(*pixels)); in WriteBMPImage()
2179 bmp_info.image_size=(unsigned int) EncodeImage(image,bytes_per_line, in WriteBMPImage()
2190 if (image->debug != MagickFalse) in WriteBMPImage()
2194 if (image->storage_class == DirectClass) in WriteBMPImage()
2201 " Image depth=%.20g",(double) image->depth); in WriteBMPImage()
2202 if (image->alpha_trait != UndefinedPixelTrait) in WriteBMPImage()
2255 (void) WriteBlob(image,2,(unsigned char *) "BM"); in WriteBMPImage()
2256 (void) WriteBlobLSBLong(image,bmp_info.file_size); in WriteBMPImage()
2257 (void) WriteBlobLSBLong(image,bmp_info.ba_offset); /* always 0 */ in WriteBMPImage()
2258 (void) WriteBlobLSBLong(image,bmp_info.offset_bits); in WriteBMPImage()
2264 (void) WriteBlobLSBLong(image,bmp_info.size); in WriteBMPImage()
2265 (void) WriteBlobLSBSignedShort(image,(signed short) bmp_info.width); in WriteBMPImage()
2266 (void) WriteBlobLSBSignedShort(image,(signed short) bmp_info.height); in WriteBMPImage()
2267 (void) WriteBlobLSBShort(image,bmp_info.planes); in WriteBMPImage()
2268 (void) WriteBlobLSBShort(image,bmp_info.bits_per_pixel); in WriteBMPImage()
2275 (void) WriteBlobLSBLong(image,bmp_info.size); in WriteBMPImage()
2276 (void) WriteBlobLSBSignedLong(image,(signed int) bmp_info.width); in WriteBMPImage()
2277 (void) WriteBlobLSBSignedLong(image,(signed int) bmp_info.height); in WriteBMPImage()
2278 (void) WriteBlobLSBShort(image,bmp_info.planes); in WriteBMPImage()
2279 (void) WriteBlobLSBShort(image,bmp_info.bits_per_pixel); in WriteBMPImage()
2280 (void) WriteBlobLSBLong(image,bmp_info.compression); in WriteBMPImage()
2281 (void) WriteBlobLSBLong(image,bmp_info.image_size); in WriteBMPImage()
2282 (void) WriteBlobLSBLong(image,bmp_info.x_pixels); in WriteBMPImage()
2283 (void) WriteBlobLSBLong(image,bmp_info.y_pixels); in WriteBMPImage()
2284 (void) WriteBlobLSBLong(image,bmp_info.number_colors); in WriteBMPImage()
2285 (void) WriteBlobLSBLong(image,bmp_info.colors_important); in WriteBMPImage()
2287 if ((type > 3) && ((image->alpha_trait != UndefinedPixelTrait) || in WriteBMPImage()
2293 (void) WriteBlobLSBLong(image,bmp_info.red_mask); in WriteBMPImage()
2294 (void) WriteBlobLSBLong(image,bmp_info.green_mask); in WriteBMPImage()
2295 (void) WriteBlobLSBLong(image,bmp_info.blue_mask); in WriteBMPImage()
2296 (void) WriteBlobLSBLong(image,bmp_info.alpha_mask); in WriteBMPImage()
2298 (void) WriteBlobLSBLong(image,0x4D424544U); /* PROFILE_EMBEDDED */ in WriteBMPImage()
2300 (void) WriteBlobLSBLong(image,0x73524742U); /* sRGB */ in WriteBMPImage()
2301 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2302 (image->chromaticity.red_primary.x*0x40000000)); in WriteBMPImage()
2303 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2304 (image->chromaticity.red_primary.y*0x40000000)); in WriteBMPImage()
2305 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2306 ((1.000f-(image->chromaticity.red_primary.x+ in WriteBMPImage()
2307 image->chromaticity.red_primary.y))*0x40000000)); in WriteBMPImage()
2308 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2309 (image->chromaticity.green_primary.x*0x40000000)); in WriteBMPImage()
2310 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2311 (image->chromaticity.green_primary.y*0x40000000)); in WriteBMPImage()
2312 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2313 ((1.000f-(image->chromaticity.green_primary.x+ in WriteBMPImage()
2314 image->chromaticity.green_primary.y))*0x40000000)); in WriteBMPImage()
2315 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2316 (image->chromaticity.blue_primary.x*0x40000000)); in WriteBMPImage()
2317 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2318 (image->chromaticity.blue_primary.y*0x40000000)); in WriteBMPImage()
2319 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2320 ((1.000f-(image->chromaticity.blue_primary.x+ in WriteBMPImage()
2321 image->chromaticity.blue_primary.y))*0x40000000)); in WriteBMPImage()
2322 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2324 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2326 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2328 if ((image->rendering_intent != UndefinedIntent) || in WriteBMPImage()
2334 switch ((int) image->rendering_intent) in WriteBMPImage()
2362 (void) WriteBlobLSBLong(image,(unsigned int) intent); in WriteBMPImage()
2363 (void) WriteBlobLSBLong(image,(unsigned int) profile_data); in WriteBMPImage()
2364 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2366 (void) WriteBlobLSBLong(image,0x00); /* reserved */ in WriteBMPImage()
2369 if (image->storage_class == PseudoClass) in WriteBMPImage()
2377 if (image->debug != MagickFalse) in WriteBMPImage()
2379 " Colormap: %.20g entries",(double) image->colors); in WriteBMPImage()
2388 … for (i=0; i < (ssize_t) MagickMin((ssize_t) image->colors,(ssize_t) bmp_info.number_colors); i++) in WriteBMPImage()
2390 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].blue)); in WriteBMPImage()
2391 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].green)); in WriteBMPImage()
2392 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].red)); in WriteBMPImage()
2405 (void) WriteBlob(image,(size_t) (3*(1L << bmp_info.bits_per_pixel)), in WriteBMPImage()
2408 (void) WriteBlob(image,(size_t) (4*(1L << bmp_info.bits_per_pixel)), in WriteBMPImage()
2412 if (image->debug != MagickFalse) in WriteBMPImage()
2415 (void) WriteBlob(image,(size_t) bmp_info.image_size,pixels); in WriteBMPImage()
2418 if (image->debug != MagickFalse) in WriteBMPImage()
2421 (void) WriteBlob(image,(size_t) profile_size,GetStringInfoDatum(profile)); in WriteBMPImage()
2423 (void) WriteBlob(image,(size_t) profile_size_pad,"\0\0\0"); in WriteBMPImage()
2426 if (GetNextImageInList(image) == (Image *) NULL) in WriteBMPImage()
2428 image=SyncNextImageInList(image); in WriteBMPImage()
2429 status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); in WriteBMPImage()
2433 (void) CloseBlob(image); in WriteBMPImage()