From d1f5c0d0659a639cb7b2fb7262331427d7d488d1 Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 26 Apr 2016 10:21:41 -0400 Subject: [PATCH] ... --- MagickCore/blob-private.h | 2 + MagickCore/blob.c | 97 +++++++++++++++++++++++++++++++++++++++ coders/bmp.c | 8 ++-- configure | 2 +- 4 files changed, 104 insertions(+), 5 deletions(-) diff --git a/MagickCore/blob-private.h b/MagickCore/blob-private.h index 25e45a240..c9f2f343e 100644 --- a/MagickCore/blob-private.h +++ b/MagickCore/blob-private.h @@ -115,6 +115,8 @@ extern MagickExport ssize_t WriteBlobShort(Image *,const unsigned short), WriteBlobLSBLong(Image *,const unsigned int), WriteBlobLSBShort(Image *,const unsigned short), + WriteBlobLSBSignedLong(Image *,const signed int), + WriteBlobLSBSignedShort(Image *,const signed short), WriteBlobMSBLong(Image *,const unsigned int), WriteBlobMSBLongLong(Image *,const MagickSizeType), WriteBlobMSBShort(Image *,const unsigned short), diff --git a/MagickCore/blob.c b/MagickCore/blob.c index 4d6f08deb..d84a9cf1e 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -4813,6 +4813,103 @@ MagickExport ssize_t WriteBlobLSBShort(Image *image,const unsigned short value) % % % % % % ++ W r i t e B l o b L S B S i g n e d L o n g % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% WriteBlobLSBSignedLong() writes a signed value as a 32-bit quantity in +% least-significant byte first order. +% +% The format of the WriteBlobLSBSignedLong method is: +% +% ssize_t WriteBlobLSBSignedLong(Image *image,const signed int value) +% +% A description of each parameter follows. +% +% o image: the image. +% +% o value: Specifies the value to write. +% +*/ +MagickExport ssize_t WriteBlobLSBSignedLong(Image *image,const signed int value) +{ + union + { + unsigned int + unsigned_value; + + signed int + signed_value; + } quantum; + + unsigned char + buffer[4]; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + quantum.signed_value=value; + buffer[0]=(unsigned char) quantum.unsigned_value; + buffer[1]=(unsigned char) (quantum.unsigned_value >> 8); + buffer[2]=(unsigned char) (quantum.unsigned_value >> 16); + buffer[3]=(unsigned char) (quantum.unsigned_value >> 24); + return(WriteBlobStream(image,4,buffer)); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % ++ W r i t e B l o b L S B S i g n e d S h o r t % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% WriteBlobLSBSignedShort() writes a signed short value as a 16-bit quantity +% in least-significant byte first order. +% +% The format of the WriteBlobLSBSignedShort method is: +% +% ssize_t WriteBlobLSBSignedShort(Image *image,const signed short value) +% +% A description of each parameter follows. +% +% o image: the image. +% +% o value: Specifies the value to write. +% +*/ +MagickExport ssize_t WriteBlobLSBSignedShort(Image *image, + const signed short value) +{ + union + { + unsigned short + unsigned_value; + + signed short + signed_value; + } quantum; + + unsigned char + buffer[2]; + + assert(image != (Image *) NULL); + assert(image->signature == MagickCoreSignature); + quantum.signed_value=value; + buffer[0]=(unsigned char) quantum.unsigned_value; + buffer[1]=(unsigned char) (quantum.unsigned_value >> 8); + return(WriteBlobStream(image,2,buffer)); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % + W r i t e B l o b M S B L o n g % % % % % diff --git a/coders/bmp.c b/coders/bmp.c index a34b088dc..b42b9ff05 100644 --- a/coders/bmp.c +++ b/coders/bmp.c @@ -2000,8 +2000,8 @@ static MagickBooleanType WriteBMPImage(const ImageInfo *image_info,Image *image, Write 12-byte version 2 bitmap header. */ (void) WriteBlobLSBLong(image,bmp_info.size); - (void) WriteBlobLSBShort(image,(unsigned short) bmp_info.width); - (void) WriteBlobLSBShort(image,(unsigned short) bmp_info.height); + (void) WriteBlobLSBSignedShort(image,bmp_info.width); + (void) WriteBlobLSBSignedShort(image,bmp_info.height); (void) WriteBlobLSBShort(image,bmp_info.planes); (void) WriteBlobLSBShort(image,bmp_info.bits_per_pixel); } @@ -2011,8 +2011,8 @@ static MagickBooleanType WriteBMPImage(const ImageInfo *image_info,Image *image, Write 40-byte version 3+ bitmap header. */ (void) WriteBlobLSBLong(image,bmp_info.size); - (void) WriteBlobLSBLong(image,(unsigned int) bmp_info.width); - (void) WriteBlobLSBLong(image,(unsigned int) bmp_info.height); + (void) WriteBlobLSBSignedLong(image,bmp_info.width); + (void) WriteBlobLSBSignedLong(image,bmp_info.height); (void) WriteBlobLSBShort(image,bmp_info.planes); (void) WriteBlobLSBShort(image,bmp_info.bits_per_pixel); (void) WriteBlobLSBLong(image,bmp_info.compression); diff --git a/configure b/configure index 5ca507b82..ca5415556 100755 --- a/configure +++ b/configure @@ -24506,7 +24506,7 @@ fi # Check additional headers -for ac_header in arm/limits.h arpa/inet.h complex.h errno.h fcntl.h limits.h linux/unistd.h locale.h machine/param.h mach-o/dyld.h netinet/in.h OS.h process.h sun_prefetch.h stdarg.h sys/ipc.h sys/mman.h sys/resource.h sys/sendfile.h sys/socket.h sys/syslimits.h sys/time.h sys/timeb.h sys/times.h sys/wait.h wchar.h xlocale.h +for ac_header in arm/limits.h arpa/inet.h complex.h errno.h fcntl.h limits.h linux/unistd.h locale.h machine/param.h mach-o/dyld.h netinet/in.h OS.h process.h sun_prefetch.h stdarg.h sys/ipc.h sys/mman.h sys/resource.h sys/sendfile.h sys/socket.h sys/syslimits.h sys/time.h sys/timeb.h sys/times.h sys/wait.h utime.h wchar.h xlocale.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -- 2.40.0