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
575 image=AcquireImage(image_info,exception); in ReadBMPImage()
576 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); in ReadBMPImage()
579 image=DestroyImageList(image); in ReadBMPImage()
589 count=ReadBlob(image,2,magick); in ReadBMPImage()
592 blob_size=GetBlobSize(image); in ReadBMPImage()
604 start_position=TellBlob(image)-2; in ReadBMPImage()
608 bmp_info.file_size=ReadBlobLSBLong(image); in ReadBMPImage()
609 bmp_info.ba_offset=ReadBlobLSBLong(image); in ReadBMPImage()
610 bmp_info.offset_bits=ReadBlobLSBLong(image); in ReadBMPImage()
611 count=ReadBlob(image,2,magick); in ReadBMPImage()
615 if (image->debug != MagickFalse) in ReadBMPImage()
621 bmp_info.file_size=ReadBlobLSBLong(image); in ReadBMPImage()
622 (void) ReadBlobLSBLong(image); in ReadBMPImage()
623 bmp_info.offset_bits=ReadBlobLSBLong(image); in ReadBMPImage()
624 bmp_info.size=ReadBlobLSBLong(image); in ReadBMPImage()
625 if (image->debug != MagickFalse) in ReadBMPImage()
635 (void) CopyMagickString(image->magick,"BMP2",MagickPathExtent); in ReadBMPImage()
636 bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image)); in ReadBMPImage()
637 bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image)); in ReadBMPImage()
638 bmp_info.planes=ReadBlobLSBShort(image); in ReadBMPImage()
639 bmp_info.bits_per_pixel=ReadBlobLSBShort(image); in ReadBMPImage()
646 if (image->debug != MagickFalse) in ReadBMPImage()
660 bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image); in ReadBMPImage()
661 bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image); in ReadBMPImage()
662 bmp_info.planes=ReadBlobLSBShort(image); in ReadBMPImage()
663 bmp_info.bits_per_pixel=ReadBlobLSBShort(image); in ReadBMPImage()
664 bmp_info.compression=ReadBlobLSBLong(image); in ReadBMPImage()
667 bmp_info.image_size=ReadBlobLSBLong(image); in ReadBMPImage()
668 bmp_info.x_pixels=ReadBlobLSBLong(image); in ReadBMPImage()
669 bmp_info.y_pixels=ReadBlobLSBLong(image); in ReadBMPImage()
670 bmp_info.number_colors=ReadBlobLSBLong(image); in ReadBMPImage()
674 bmp_info.colors_important=ReadBlobLSBLong(image); in ReadBMPImage()
676 if (image->debug != MagickFalse) in ReadBMPImage()
734 bmp_info.red_mask=ReadBlobLSBLong(image); in ReadBMPImage()
735 bmp_info.green_mask=ReadBlobLSBLong(image); in ReadBMPImage()
736 bmp_info.blue_mask=ReadBlobLSBLong(image); in ReadBMPImage()
746 bmp_info.alpha_mask=ReadBlobLSBLong(image); in ReadBMPImage()
747 bmp_info.colorspace=ReadBlobLSBSignedLong(image); in ReadBMPImage()
752 bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
753 bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
754 bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
755 bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
756 bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
757 bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
758 bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
759 bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
760 bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM; in ReadBMPImage()
767 image->chromaticity.red_primary.x=bmp_info.red_primary.x; in ReadBMPImage()
768 image->chromaticity.red_primary.y=bmp_info.red_primary.y; in ReadBMPImage()
775 image->chromaticity.green_primary.x=bmp_info.green_primary.x; in ReadBMPImage()
776 image->chromaticity.green_primary.y=bmp_info.green_primary.y; in ReadBMPImage()
783 image->chromaticity.blue_primary.x=bmp_info.blue_primary.x; in ReadBMPImage()
784 image->chromaticity.blue_primary.y=bmp_info.blue_primary.y; in ReadBMPImage()
789 bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)/0x10000; in ReadBMPImage()
790 bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)/0x10000; in ReadBMPImage()
791 bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)/0x10000; in ReadBMPImage()
795 image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+ in ReadBMPImage()
799 (void) CopyMagickString(image->magick,"BMP3",MagickPathExtent); in ReadBMPImage()
809 intent=ReadBlobLSBLong(image); in ReadBMPImage()
814 image->rendering_intent=SaturationIntent; in ReadBMPImage()
819 image->rendering_intent=RelativeIntent; in ReadBMPImage()
824 image->rendering_intent=PerceptualIntent; in ReadBMPImage()
829 image->rendering_intent=AbsoluteIntent; in ReadBMPImage()
833 profile_data=(MagickOffsetType)ReadBlobLSBLong(image); in ReadBMPImage()
834 profile_size=(MagickOffsetType)ReadBlobLSBLong(image); in ReadBMPImage()
835 (void) ReadBlobLSBLong(image); /* Reserved byte */ in ReadBMPImage()
847 image->filename); in ReadBMPImage()
871 image->compression=NoCompression; in ReadBMPImage()
875 image->compression=RLECompression; in ReadBMPImage()
886 image->columns=(size_t) MagickAbsoluteValue(bmp_info.width); in ReadBMPImage()
887 image->rows=(size_t) MagickAbsoluteValue(bmp_info.height); in ReadBMPImage()
888 image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8; in ReadBMPImage()
889 image->alpha_trait=((bmp_info.alpha_mask != 0) && in ReadBMPImage()
897 image->storage_class=PseudoClass; in ReadBMPImage()
898 image->colors=bmp_info.number_colors; in ReadBMPImage()
900 if (image->colors == 0) in ReadBMPImage()
901 image->colors=one << bmp_info.bits_per_pixel; in ReadBMPImage()
903 image->resolution.x=(double) bmp_info.x_pixels/100.0; in ReadBMPImage()
904 image->resolution.y=(double) bmp_info.y_pixels/100.0; in ReadBMPImage()
905 image->units=PixelsPerCentimeterResolution; in ReadBMPImage()
907 if (image->scene >= (image_info->scene+image_info->number_scenes-1)) in ReadBMPImage()
909 status=SetImageExtent(image,image->columns,image->rows,exception); in ReadBMPImage()
911 return(DestroyImageList(image)); in ReadBMPImage()
912 if (image->storage_class == PseudoClass) in ReadBMPImage()
923 if (image->debug != MagickFalse) in ReadBMPImage()
925 " Reading colormap of %.20g colors",(double) image->colors); in ReadBMPImage()
926 if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) in ReadBMPImage()
929 image->colors,4*sizeof(*bmp_colormap)); in ReadBMPImage()
936 offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET); in ReadBMPImage()
942 count=ReadBlob(image,packet_size*image->colors,bmp_colormap); in ReadBMPImage()
943 if (count != (ssize_t) (packet_size*image->colors)) in ReadBMPImage()
950 for (i=0; i < (ssize_t) image->colors; i++) in ReadBMPImage()
952 image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum(*p++); in ReadBMPImage()
953 image->colormap[i].green=(MagickRealType) ScaleCharToQuantum(*p++); in ReadBMPImage()
954 image->colormap[i].red=(MagickRealType) ScaleCharToQuantum(*p++); in ReadBMPImage()
966 offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET); in ReadBMPImage()
971 bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32); in ReadBMPImage()
972 length=(size_t) bytes_per_line*image->rows; in ReadBMPImage()
978 pixel_info=AcquireVirtualMemory(image->rows, in ReadBMPImage()
979 MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); in ReadBMPImage()
983 if (image->debug != MagickFalse) in ReadBMPImage()
986 count=ReadBlob(image,length,pixels); in ReadBMPImage()
999 pixel_info=AcquireVirtualMemory(image->rows, in ReadBMPImage()
1000 MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); in ReadBMPImage()
1004 status=DecodeImage(image,bmp_info.compression,pixels, in ReadBMPImage()
1005 image->columns*image->rows); in ReadBMPImage()
1025 if ((image->alpha_trait == UndefinedPixelTrait) && in ReadBMPImage()
1028 bytes_per_line=4*(image->columns); in ReadBMPImage()
1029 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1031 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1032 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1036 image->alpha_trait=BlendPixelTrait; in ReadBMPImage()
1044 bmp_info.alpha_mask=image->alpha_trait != UndefinedPixelTrait ? in ReadBMPImage()
1137 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1139 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1140 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1143 for (x=0; x < ((ssize_t) image->columns-7); x+=8) in ReadBMPImage()
1148 SetPixelIndex(image,index,q); in ReadBMPImage()
1149 q+=GetPixelChannels(image); in ReadBMPImage()
1153 if ((image->columns % 8) != 0) in ReadBMPImage()
1155 for (bit=0; bit < (image->columns % 8); bit++) in ReadBMPImage()
1158 SetPixelIndex(image,index,q); in ReadBMPImage()
1159 q+=GetPixelChannels(image); in ReadBMPImage()
1163 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1165 if (image->previous == (Image *) NULL) in ReadBMPImage()
1167 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1168 (image->rows-y),image->rows); in ReadBMPImage()
1173 (void) SyncImage(image,exception); in ReadBMPImage()
1181 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1183 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1184 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1187 for (x=0; x < ((ssize_t) image->columns-1); x+=2) in ReadBMPImage()
1189 ValidateColormapValue(image,(ssize_t) ((*p >> 4) & 0x0f),&index, in ReadBMPImage()
1191 SetPixelIndex(image,index,q); in ReadBMPImage()
1192 q+=GetPixelChannels(image); in ReadBMPImage()
1193 ValidateColormapValue(image,(ssize_t) (*p & 0x0f),&index,exception); in ReadBMPImage()
1194 SetPixelIndex(image,index,q); in ReadBMPImage()
1195 q+=GetPixelChannels(image); in ReadBMPImage()
1198 if ((image->columns % 2) != 0) in ReadBMPImage()
1200 ValidateColormapValue(image,(ssize_t) ((*p >> 4) & 0xf),&index, in ReadBMPImage()
1202 SetPixelIndex(image,index,q); in ReadBMPImage()
1203 q+=GetPixelChannels(image); in ReadBMPImage()
1207 if (x < (ssize_t) image->columns) in ReadBMPImage()
1209 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1211 if (image->previous == (Image *) NULL) in ReadBMPImage()
1213 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1214 (image->rows-y),image->rows); in ReadBMPImage()
1219 (void) SyncImage(image,exception); in ReadBMPImage()
1229 bytes_per_line=image->columns; in ReadBMPImage()
1230 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1232 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1233 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1236 for (x=(ssize_t) image->columns; x != 0; --x) in ReadBMPImage()
1238 ValidateColormapValue(image,(ssize_t) *p++,&index,exception); in ReadBMPImage()
1239 SetPixelIndex(image,index,q); in ReadBMPImage()
1240 q+=GetPixelChannels(image); in ReadBMPImage()
1242 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1244 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1245 if (image->previous == (Image *) NULL) in ReadBMPImage()
1247 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1248 (image->rows-y),image->rows); in ReadBMPImage()
1253 (void) SyncImage(image,exception); in ReadBMPImage()
1272 bytes_per_line=2*(image->columns+image->columns % 2); in ReadBMPImage()
1273 image->storage_class=DirectClass; in ReadBMPImage()
1274 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1276 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1277 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1280 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1301 SetPixelRed(image,ScaleShortToQuantum((unsigned short) red),q); in ReadBMPImage()
1302 SetPixelGreen(image,ScaleShortToQuantum((unsigned short) green),q); in ReadBMPImage()
1303 SetPixelBlue(image,ScaleShortToQuantum((unsigned short) blue),q); in ReadBMPImage()
1304 SetPixelAlpha(image,OpaqueAlpha,q); in ReadBMPImage()
1305 if (image->alpha_trait != UndefinedPixelTrait) in ReadBMPImage()
1310 SetPixelAlpha(image,ScaleShortToQuantum( in ReadBMPImage()
1313 q+=GetPixelChannels(image); in ReadBMPImage()
1315 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1317 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1318 if (image->previous == (Image *) NULL) in ReadBMPImage()
1320 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1321 (image->rows-y),image->rows); in ReadBMPImage()
1333 bytes_per_line=4*((image->columns*24+31)/32); in ReadBMPImage()
1334 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1336 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1337 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1340 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1342 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); in ReadBMPImage()
1343 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); in ReadBMPImage()
1344 SetPixelRed(image,ScaleCharToQuantum(*p++),q); in ReadBMPImage()
1345 SetPixelAlpha(image,OpaqueAlpha,q); in ReadBMPImage()
1346 q+=GetPixelChannels(image); in ReadBMPImage()
1348 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1350 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1351 if (image->previous == (Image *) NULL) in ReadBMPImage()
1353 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1354 (image->rows-y),image->rows); in ReadBMPImage()
1373 bytes_per_line=4*(image->columns); in ReadBMPImage()
1374 for (y=(ssize_t) image->rows-1; y >= 0; y--) in ReadBMPImage()
1380 p=pixels+(image->rows-y-1)*bytes_per_line; in ReadBMPImage()
1381 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); in ReadBMPImage()
1384 for (x=0; x < (ssize_t) image->columns; x++) in ReadBMPImage()
1399 SetPixelRed(image,ScaleShortToQuantum((unsigned short) red),q); in ReadBMPImage()
1400 SetPixelGreen(image,ScaleShortToQuantum((unsigned short) green),q); in ReadBMPImage()
1401 SetPixelBlue(image,ScaleShortToQuantum((unsigned short) blue),q); in ReadBMPImage()
1402 SetPixelAlpha(image,OpaqueAlpha,q); in ReadBMPImage()
1403 if (image->alpha_trait != UndefinedPixelTrait) in ReadBMPImage()
1408 SetPixelAlpha(image,ScaleShortToQuantum( in ReadBMPImage()
1411 q+=GetPixelChannels(image); in ReadBMPImage()
1413 if (SyncAuthenticPixels(image,exception) == MagickFalse) in ReadBMPImage()
1415 offset=(MagickOffsetType) (image->rows-y-1); in ReadBMPImage()
1416 if (image->previous == (Image *) NULL) in ReadBMPImage()
1418 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) in ReadBMPImage()
1419 (image->rows-y),image->rows); in ReadBMPImage()
1435 if (EOFBlob(image) != MagickFalse) in ReadBMPImage()
1438 image->filename); in ReadBMPImage()
1449 flipped_image=FlipImage(image,exception); in ReadBMPImage()
1452 DuplicateBlob(flipped_image,image); in ReadBMPImage()
1453 ReplaceImageInList(&image, flipped_image); in ReadBMPImage()
1454 image=flipped_image; in ReadBMPImage()
1470 if ((offset < TellBlob(image)) || in ReadBMPImage()
1471 (SeekBlob(image,offset,SEEK_SET) != offset) || in ReadBMPImage()
1478 if (ReadBlob(image,(size_t) profile_size,datum) == (ssize_t) profile_size) in ReadBMPImage()
1492 if (image->debug != MagickFalse) in ReadBMPImage()
1495 (void) SetImageProfile(image,"icc",profile,exception); in ReadBMPImage()
1503 if (image->scene >= (image_info->scene+image_info->number_scenes-1)) in ReadBMPImage()
1507 if ((offset < TellBlob(image)) || in ReadBMPImage()
1508 (SeekBlob(image,offset,SEEK_SET) != offset)) in ReadBMPImage()
1511 count=ReadBlob(image,2,magick); in ReadBMPImage()
1517 AcquireNextImage(image_info,image,exception); in ReadBMPImage()
1518 if (GetNextImageInList(image) == (Image *) NULL) in ReadBMPImage()
1523 image=SyncNextImageInList(image); in ReadBMPImage()
1524 status=SetImageProgress(image,LoadImagesTag,TellBlob(image),blob_size); in ReadBMPImage()
1529 (void) CloseBlob(image); in ReadBMPImage()
1531 return(DestroyImageList(image)); in ReadBMPImage()
1532 return(GetFirstImageInList(image)); in ReadBMPImage()
1642 static MagickBooleanType WriteBMPImage(const ImageInfo *image_info,Image *image, in WriteBMPImage() argument
1699 assert(image != (Image *) NULL); in WriteBMPImage()
1700 assert(image->signature == MagickCoreSignature); in WriteBMPImage()
1701 if (image->debug != MagickFalse) in WriteBMPImage()
1702 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); in WriteBMPImage()
1705 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); in WriteBMPImage()
1708 if (((image->columns << 3) != (size_t) ((int) (image->columns << 3))) || in WriteBMPImage()
1709 ((image->rows << 3) != (size_t) ((int) (image->rows << 3)))) in WriteBMPImage()
1730 imageListLength=GetImageListLength(image); in WriteBMPImage()
1736 if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) in WriteBMPImage()
1737 (void) TransformImageColorspace(image,sRGBColorspace,exception); in WriteBMPImage()
1749 if ((image->storage_class == PseudoClass) && (image->colors > 256)) in WriteBMPImage()
1750 (void) SetImageStorageClass(image,DirectClass,exception); in WriteBMPImage()
1751 if (image->storage_class != DirectClass) in WriteBMPImage()
1757 if (image->colors <= 2) in WriteBMPImage()
1760 if (image->colors <= 16) in WriteBMPImage()
1763 if (image->colors <= 256) in WriteBMPImage()
1768 if (image->alpha_trait != UndefinedPixelTrait) in WriteBMPImage()
1769 (void) SetImageStorageClass(image,DirectClass,exception); in WriteBMPImage()
1771 if ((size_t) bmp_info.number_colors < image->colors) in WriteBMPImage()
1772 (void) SetImageStorageClass(image,DirectClass,exception); in WriteBMPImage()
1784 if (image->storage_class == DirectClass) in WriteBMPImage()
1793 if (image->alpha_trait != UndefinedPixelTrait) in WriteBMPImage()
1840 (image->alpha_trait != UndefinedPixelTrait) ? 32 : 24); in WriteBMPImage()
1842 (image->alpha_trait != UndefinedPixelTrait) ? BI_BITFIELDS : BI_RGB); in WriteBMPImage()
1843 if ((type == 3) && (image->alpha_trait != UndefinedPixelTrait)) in WriteBMPImage()
1851 bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32); in WriteBMPImage()
1853 profile=GetImageProfile(image,"icc"); in WriteBMPImage()
1854 have_color_info=(image->rendering_intent != UndefinedIntent) || in WriteBMPImage()
1855 (profile != (StringInfo *) NULL) || (image->gamma != 0.0) ? MagickTrue : in WriteBMPImage()
1860 if ((type == 3) || ((image->alpha_trait == UndefinedPixelTrait) && in WriteBMPImage()
1873 if ((image->rendering_intent != UndefinedIntent) || in WriteBMPImage()
1882 if (((ssize_t) image->columns != (ssize_t) ((signed int) image->columns)) || in WriteBMPImage()
1883 ((ssize_t) image->rows != (ssize_t) ((signed int) image->rows))) in WriteBMPImage()
1885 bmp_info.width=(ssize_t) image->columns; in WriteBMPImage()
1886 bmp_info.height=(ssize_t) image->rows; in WriteBMPImage()
1888 bmp_info.image_size=(unsigned int) (bytes_per_line*image->rows); in WriteBMPImage()
1892 switch (image->units) in WriteBMPImage()
1897 bmp_info.x_pixels=(unsigned int) (100.0*image->resolution.x/2.54); in WriteBMPImage()
1898 bmp_info.y_pixels=(unsigned int) (100.0*image->resolution.y/2.54); in WriteBMPImage()
1903 bmp_info.x_pixels=(unsigned int) (100.0*image->resolution.x); in WriteBMPImage()
1904 bmp_info.y_pixels=(unsigned int) (100.0*image->resolution.y); in WriteBMPImage()
1912 pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line, in WriteBMPImage()
1913 image->columns+256UL)*sizeof(*pixels)); in WriteBMPImage()
1929 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
1934 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
1937 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
1940 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
1943 byte|=GetPixelIndex(image,p) != 0 ? 0x01 : 0x00; in WriteBMPImage()
1951 p+=GetPixelChannels(image); in WriteBMPImage()
1958 offset=(ssize_t) (image->columns+7)/8; in WriteBMPImage()
1961 if (image->previous == (Image *) NULL) in WriteBMPImage()
1963 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
1964 image->rows); in WriteBMPImage()
1983 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
1985 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
1988 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
1991 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
1994 byte|=((unsigned int) GetPixelIndex(image,p) & 0x0f); in WriteBMPImage()
2002 p+=GetPixelChannels(image); in WriteBMPImage()
2009 offset=(ssize_t) (image->columns+1)/2; in WriteBMPImage()
2012 if (image->previous == (Image *) NULL) in WriteBMPImage()
2014 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2015 image->rows); in WriteBMPImage()
2027 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2029 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2032 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2033 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2035 *q++=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); in WriteBMPImage()
2036 p+=GetPixelChannels(image); in WriteBMPImage()
2040 if (image->previous == (Image *) NULL) in WriteBMPImage()
2042 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2043 image->rows); in WriteBMPImage()
2055 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2057 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2060 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2061 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2070 GetPixelAlpha(image,p),15) << 12); in WriteBMPImage()
2072 GetPixelRed(image,p),15) << 8); in WriteBMPImage()
2074 GetPixelGreen(image,p),15) << 4); in WriteBMPImage()
2076 GetPixelBlue(image,p),15)); in WriteBMPImage()
2081 GetPixelRed(image,p),31) << 11); in WriteBMPImage()
2083 GetPixelGreen(image,p),63) << 5); in WriteBMPImage()
2085 GetPixelBlue(image,p),31)); in WriteBMPImage()
2091 GetPixelAlpha(image,p),1) << 15); in WriteBMPImage()
2093 GetPixelRed(image,p),31) << 10); in WriteBMPImage()
2095 GetPixelGreen(image,p),31) << 5); in WriteBMPImage()
2097 GetPixelBlue(image,p),31)); in WriteBMPImage()
2101 p+=GetPixelChannels(image); in WriteBMPImage()
2103 for (x=2L*(ssize_t) image->columns; x < (ssize_t) bytes_per_line; x++) in WriteBMPImage()
2105 if (image->previous == (Image *) NULL) in WriteBMPImage()
2107 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2108 image->rows); in WriteBMPImage()
2120 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2122 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2125 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2126 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2128 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); in WriteBMPImage()
2129 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); in WriteBMPImage()
2130 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); in WriteBMPImage()
2131 p+=GetPixelChannels(image); in WriteBMPImage()
2133 for (x=3L*(ssize_t) image->columns; x < (ssize_t) bytes_per_line; x++) in WriteBMPImage()
2135 if (image->previous == (Image *) NULL) in WriteBMPImage()
2137 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2138 image->rows); in WriteBMPImage()
2150 for (y=0; y < (ssize_t) image->rows; y++) in WriteBMPImage()
2152 p=GetVirtualPixels(image,0,y,image->columns,1,exception); in WriteBMPImage()
2155 q=pixels+(image->rows-y-1)*bytes_per_line; in WriteBMPImage()
2156 for (x=0; x < (ssize_t) image->columns; x++) in WriteBMPImage()
2158 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); in WriteBMPImage()
2159 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); in WriteBMPImage()
2160 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); in WriteBMPImage()
2161 *q++=ScaleQuantumToChar(GetPixelAlpha(image,p)); in WriteBMPImage()
2162 p+=GetPixelChannels(image); in WriteBMPImage()
2164 if (image->previous == (Image *) NULL) in WriteBMPImage()
2166 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, in WriteBMPImage()
2167 image->rows); in WriteBMPImage()
2185 (image->rows+2)*sizeof(*pixels)); in WriteBMPImage()
2193 bmp_info.image_size=(unsigned int) EncodeImage(image,bytes_per_line, in WriteBMPImage()
2204 if (image->debug != MagickFalse) in WriteBMPImage()
2208 if (image->storage_class == DirectClass) in WriteBMPImage()
2215 " Image depth=%.20g",(double) image->depth); in WriteBMPImage()
2216 if (image->alpha_trait != UndefinedPixelTrait) in WriteBMPImage()
2269 (void) WriteBlob(image,2,(unsigned char *) "BM"); in WriteBMPImage()
2270 (void) WriteBlobLSBLong(image,bmp_info.file_size); in WriteBMPImage()
2271 (void) WriteBlobLSBLong(image,bmp_info.ba_offset); /* always 0 */ in WriteBMPImage()
2272 (void) WriteBlobLSBLong(image,bmp_info.offset_bits); in WriteBMPImage()
2278 (void) WriteBlobLSBLong(image,bmp_info.size); in WriteBMPImage()
2279 (void) WriteBlobLSBSignedShort(image,(signed short) bmp_info.width); in WriteBMPImage()
2280 (void) WriteBlobLSBSignedShort(image,(signed short) bmp_info.height); in WriteBMPImage()
2281 (void) WriteBlobLSBShort(image,bmp_info.planes); in WriteBMPImage()
2282 (void) WriteBlobLSBShort(image,bmp_info.bits_per_pixel); in WriteBMPImage()
2289 (void) WriteBlobLSBLong(image,bmp_info.size); in WriteBMPImage()
2290 (void) WriteBlobLSBSignedLong(image,(signed int) bmp_info.width); in WriteBMPImage()
2291 (void) WriteBlobLSBSignedLong(image,(signed int) bmp_info.height); in WriteBMPImage()
2292 (void) WriteBlobLSBShort(image,bmp_info.planes); in WriteBMPImage()
2293 (void) WriteBlobLSBShort(image,bmp_info.bits_per_pixel); in WriteBMPImage()
2294 (void) WriteBlobLSBLong(image,bmp_info.compression); in WriteBMPImage()
2295 (void) WriteBlobLSBLong(image,bmp_info.image_size); in WriteBMPImage()
2296 (void) WriteBlobLSBLong(image,bmp_info.x_pixels); in WriteBMPImage()
2297 (void) WriteBlobLSBLong(image,bmp_info.y_pixels); in WriteBMPImage()
2298 (void) WriteBlobLSBLong(image,bmp_info.number_colors); in WriteBMPImage()
2299 (void) WriteBlobLSBLong(image,bmp_info.colors_important); in WriteBMPImage()
2301 if ((type > 3) && ((image->alpha_trait != UndefinedPixelTrait) || in WriteBMPImage()
2307 (void) WriteBlobLSBLong(image,bmp_info.red_mask); in WriteBMPImage()
2308 (void) WriteBlobLSBLong(image,bmp_info.green_mask); in WriteBMPImage()
2309 (void) WriteBlobLSBLong(image,bmp_info.blue_mask); in WriteBMPImage()
2310 (void) WriteBlobLSBLong(image,bmp_info.alpha_mask); in WriteBMPImage()
2312 (void) WriteBlobLSBLong(image,0x4D424544U); /* PROFILE_EMBEDDED */ in WriteBMPImage()
2314 (void) WriteBlobLSBLong(image,0x73524742U); /* sRGB */ in WriteBMPImage()
2317 if (isgreater(image->chromaticity.red_primary.x, 1.0) || in WriteBMPImage()
2318 !isgreater(image->chromaticity.red_primary.x, 0.0)) in WriteBMPImage()
2319 image->chromaticity.red_primary.x = 0.0; in WriteBMPImage()
2320 if (isgreater(image->chromaticity.red_primary.y, 1.0) || in WriteBMPImage()
2321 !isgreater(image->chromaticity.red_primary.y, 0.0)) in WriteBMPImage()
2322 image->chromaticity.red_primary.y = 0.0; in WriteBMPImage()
2323 if (isgreater(image->chromaticity.green_primary.x, 1.0) || in WriteBMPImage()
2324 !isgreater(image->chromaticity.green_primary.x, 0.0)) in WriteBMPImage()
2325 image->chromaticity.green_primary.x = 0.0; in WriteBMPImage()
2326 if (isgreater(image->chromaticity.green_primary.y, 1.0) || in WriteBMPImage()
2327 !isgreater(image->chromaticity.green_primary.y, 0.0)) in WriteBMPImage()
2328 image->chromaticity.green_primary.y = 0.0; in WriteBMPImage()
2329 if (isgreater(image->chromaticity.blue_primary.x, 1.0) || in WriteBMPImage()
2330 !isgreater(image->chromaticity.blue_primary.x, 0.0)) in WriteBMPImage()
2331 image->chromaticity.blue_primary.x = 0.0; in WriteBMPImage()
2332 if (isgreater(image->chromaticity.blue_primary.y, 1.0) || in WriteBMPImage()
2333 !isgreater(image->chromaticity.blue_primary.y, 0.0)) in WriteBMPImage()
2334 image->chromaticity.blue_primary.y = 0.0; in WriteBMPImage()
2345 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2346 (image->chromaticity.red_primary.x*0x40000000)); in WriteBMPImage()
2347 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2348 (image->chromaticity.red_primary.y*0x40000000)); in WriteBMPImage()
2349 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2350 ((1.000f-(image->chromaticity.red_primary.x+ in WriteBMPImage()
2351 image->chromaticity.red_primary.y))*0x40000000)); in WriteBMPImage()
2352 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2353 (image->chromaticity.green_primary.x*0x40000000)); in WriteBMPImage()
2354 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2355 (image->chromaticity.green_primary.y*0x40000000)); in WriteBMPImage()
2356 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2357 ((1.000f-(image->chromaticity.green_primary.x+ in WriteBMPImage()
2358 image->chromaticity.green_primary.y))*0x40000000)); in WriteBMPImage()
2359 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2360 (image->chromaticity.blue_primary.x*0x40000000)); in WriteBMPImage()
2361 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2362 (image->chromaticity.blue_primary.y*0x40000000)); in WriteBMPImage()
2363 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2364 ((1.000f-(image->chromaticity.blue_primary.x+ in WriteBMPImage()
2365 image->chromaticity.blue_primary.y))*0x40000000)); in WriteBMPImage()
2366 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2368 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2370 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2372 if ((image->rendering_intent != UndefinedIntent) || in WriteBMPImage()
2378 switch ((int) image->rendering_intent) in WriteBMPImage()
2406 (void) WriteBlobLSBLong(image,(unsigned int) intent); in WriteBMPImage()
2407 (void) WriteBlobLSBLong(image,(unsigned int) profile_data); in WriteBMPImage()
2408 (void) WriteBlobLSBLong(image,(unsigned int) in WriteBMPImage()
2410 (void) WriteBlobLSBLong(image,0x00); /* reserved */ in WriteBMPImage()
2413 if (image->storage_class == PseudoClass) in WriteBMPImage()
2421 if (image->debug != MagickFalse) in WriteBMPImage()
2423 " Colormap: %.20g entries",(double) image->colors); in WriteBMPImage()
2432 … for (i=0; i < (ssize_t) MagickMin((ssize_t) image->colors,(ssize_t) bmp_info.number_colors); i++) in WriteBMPImage()
2434 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].blue)); in WriteBMPImage()
2435 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].green)); in WriteBMPImage()
2436 *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].red)); in WriteBMPImage()
2449 (void) WriteBlob(image,(size_t) (3*(1L << bmp_info.bits_per_pixel)), in WriteBMPImage()
2452 (void) WriteBlob(image,(size_t) (4*(1L << bmp_info.bits_per_pixel)), in WriteBMPImage()
2456 if (image->debug != MagickFalse) in WriteBMPImage()
2459 (void) WriteBlob(image,(size_t) bmp_info.image_size,pixels); in WriteBMPImage()
2462 if (image->debug != MagickFalse) in WriteBMPImage()
2465 (void) WriteBlob(image,(size_t) profile_size,GetStringInfoDatum(profile)); in WriteBMPImage()
2467 (void) WriteBlob(image,(size_t) profile_size_pad,"\0\0\0"); in WriteBMPImage()
2470 if (GetNextImageInList(image) == (Image *) NULL) in WriteBMPImage()
2472 image=SyncNextImageInList(image); in WriteBMPImage()
2473 status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); in WriteBMPImage()
2477 (void) CloseBlob(image); in WriteBMPImage()