From 19cbeef3ed97e278c8635a91e1c702af84e426ed Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 25 Mar 2018 21:51:57 +0200 Subject: [PATCH] Deprecated unused methods. --- MagickCore/deprecate.c | 275 ++++++++++++++++++++++++++++++++++++++++ MagickCore/deprecate.h | 4 + MagickCore/nt-feature.c | 265 -------------------------------------- MagickCore/nt-feature.h | 4 - 4 files changed, 279 insertions(+), 269 deletions(-) diff --git a/MagickCore/deprecate.c b/MagickCore/deprecate.c index 74d0a115e..ac3b0d1f3 100644 --- a/MagickCore/deprecate.c +++ b/MagickCore/deprecate.c @@ -40,6 +40,11 @@ /* Include declarations. */ +#if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) +#define WIN32_LEAN_AND_MEAN +#define VC_EXTRALEAN +#include +#endif #include "MagickCore/studio.h" #include "MagickCore/property.h" #include "MagickCore/blob.h" @@ -52,6 +57,7 @@ #include "MagickCore/colormap.h" #include "MagickCore/colormap-private.h" #include "MagickCore/colorspace.h" +#include "MagickCore/colorspace-private.h" #include "MagickCore/composite.h" #include "MagickCore/composite-private.h" #include "MagickCore/constitute.h" @@ -121,5 +127,274 @@ MagickExport MagickBooleanType GetMagickSeekableStream( return(((magick_info->flags & CoderSeekableStreamFlag) == 0) ? MagickFalse : MagickTrue); } + +#if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % +% C r o p I m a g e T o H B i t m a p % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% CropImageToHBITMAP() extracts a specified region of the image and returns +% it as a Windows HBITMAP. While the same functionality can be accomplished by +% invoking CropImage() followed by ImageToHBITMAP(), this method is more +% efficient since it copies pixels directly to the HBITMAP. +% +% The format of the CropImageToHBITMAP method is: +% +% HBITMAP CropImageToHBITMAP(Image* image,const RectangleInfo *geometry, +% ExceptionInfo *exception) +% +% A description of each parameter follows: +% +% o image: the image. +% +% o geometry: Define the region of the image to crop with members +% x, y, width, and height. +% +% o exception: return any errors or warnings in this structure. +% +*/ +MagickExport void *CropImageToHBITMAP(Image *image, + const RectangleInfo *geometry,ExceptionInfo *exception) +{ +#define CropImageTag "Crop/Image" + + BITMAP + bitmap; + + HBITMAP + bitmapH; + + HANDLE + bitmap_bitsH; + + MagickBooleanType + proceed; + + RectangleInfo + page; + + register const Quantum + *p; + + register RGBQUAD + *q; + + RGBQUAD + *bitmap_bits; + + ssize_t + y; + + /* + Check crop geometry. + */ + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); + assert(geometry != (const RectangleInfo *) NULL); + assert(exception != (ExceptionInfo *) NULL); + assert(exception->signature == MagickCoreSignature); + if (((geometry->x+(ssize_t) geometry->width) < 0) || + ((geometry->y+(ssize_t) geometry->height) < 0) || + (geometry->x >= (ssize_t) image->columns) || + (geometry->y >= (ssize_t) image->rows)) + ThrowImageException(OptionError,"GeometryDoesNotContainImage"); + page=(*geometry); + if ((page.x+(ssize_t) page.width) > (ssize_t) image->columns) + page.width=image->columns-page.x; + if ((page.y+(ssize_t) page.height) > (ssize_t) image->rows) + page.height=image->rows-page.y; + if (page.x < 0) + { + page.width+=page.x; + page.x=0; + } + if (page.y < 0) + { + page.height+=page.y; + page.y=0; + } + + if ((page.width == 0) || (page.height == 0)) + ThrowImageException(OptionError,"GeometryDimensionsAreZero"); + /* + Initialize crop image attributes. + */ + bitmap.bmType = 0; + bitmap.bmWidth = (LONG) page.width; + bitmap.bmHeight = (LONG) page.height; + bitmap.bmWidthBytes = bitmap.bmWidth * 4; + bitmap.bmPlanes = 1; + bitmap.bmBitsPixel = 32; + bitmap.bmBits = NULL; + + bitmap_bitsH=(HANDLE) GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,page.width* + page.height*bitmap.bmBitsPixel); + if (bitmap_bitsH == NULL) + return(NULL); + bitmap_bits=(RGBQUAD *) GlobalLock((HGLOBAL) bitmap_bitsH); + if ( bitmap.bmBits == NULL ) + bitmap.bmBits = bitmap_bits; + if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) + SetImageColorspace(image,sRGBColorspace,exception); + /* + Extract crop image. + */ + q=bitmap_bits; + for (y=0; y < (ssize_t) page.height; y++) + { + register ssize_t + x; + + p=GetVirtualPixels(image,page.x,page.y+y,page.width,1,exception); + if (p == (const Quantum *) NULL) + break; + + /* Transfer pixels, scaling to Quantum */ + for( x=(ssize_t) page.width ; x> 0 ; x-- ) + { + q->rgbRed = ScaleQuantumToChar(GetPixelRed(image,p)); + q->rgbGreen = ScaleQuantumToChar(GetPixelGreen(image,p)); + q->rgbBlue = ScaleQuantumToChar(GetPixelBlue(image,p)); + q->rgbReserved = 0; + p+=GetPixelChannels(image); + q++; + } + proceed=SetImageProgress(image,CropImageTag,y,page.height); + if (proceed == MagickFalse) + break; + } + if (y < (ssize_t) page.height) + { + GlobalUnlock((HGLOBAL) bitmap_bitsH); + GlobalFree((HGLOBAL) bitmap_bitsH); + return((void *) NULL); + } + bitmap.bmBits=bitmap_bits; + bitmapH=CreateBitmapIndirect(&bitmap); + GlobalUnlock((HGLOBAL) bitmap_bitsH); + GlobalFree((HGLOBAL) bitmap_bitsH); + return((void *) bitmapH); +} +#endif + +#if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % +% I m a g e T o H B i t m a p % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ImageToHBITMAP() creates a Windows HBITMAP from an image. +% +% The format of the ImageToHBITMAP method is: +% +% HBITMAP ImageToHBITMAP(Image *image,Exceptioninfo *exception) +% +% A description of each parameter follows: +% +% o image: the image to convert. +% +*/ +MagickExport void *ImageToHBITMAP(Image *image,ExceptionInfo *exception) +{ + BITMAP + bitmap; + + HANDLE + bitmap_bitsH; + + HBITMAP + bitmapH; + + register ssize_t + x; + + register const Quantum + *p; + + register RGBQUAD + *q; + + RGBQUAD + *bitmap_bits; + + size_t + length; + + ssize_t + y; + + (void) memset(&bitmap,0,sizeof(bitmap)); + bitmap.bmType=0; + bitmap.bmWidth=(LONG) image->columns; + bitmap.bmHeight=(LONG) image->rows; + bitmap.bmWidthBytes=4*bitmap.bmWidth; + bitmap.bmPlanes=1; + bitmap.bmBitsPixel=32; + bitmap.bmBits=NULL; + length=bitmap.bmWidthBytes*bitmap.bmHeight; + bitmap_bitsH=(HANDLE) GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,length); + if (bitmap_bitsH == NULL) + { + char + *message; + + message=GetExceptionMessage(errno); + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",message); + message=DestroyString(message); + return(NULL); + } + bitmap_bits=(RGBQUAD *) GlobalLock((HGLOBAL) bitmap_bitsH); + q=bitmap_bits; + if (bitmap.bmBits == NULL) + bitmap.bmBits=bitmap_bits; + (void) SetImageColorspace(image,sRGBColorspace,exception); + for (y=0; y < (ssize_t) image->rows; y++) + { + p=GetVirtualPixels(image,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + q->rgbRed=ScaleQuantumToChar(GetPixelRed(image,p)); + q->rgbGreen=ScaleQuantumToChar(GetPixelGreen(image,p)); + q->rgbBlue=ScaleQuantumToChar(GetPixelBlue(image,p)); + q->rgbReserved=0; + p+=GetPixelChannels(image); + q++; + } + } + bitmap.bmBits=bitmap_bits; + bitmapH=CreateBitmapIndirect(&bitmap); + if (bitmapH == NULL) + { + char + *message; + + message=GetExceptionMessage(errno); + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",message); + message=DestroyString(message); + } + GlobalUnlock((HGLOBAL) bitmap_bitsH); + GlobalFree((HGLOBAL) bitmap_bitsH); + return((void *) bitmapH); +} +#endif #endif diff --git a/MagickCore/deprecate.h b/MagickCore/deprecate.h index 8742e772b..b8d772261 100644 --- a/MagickCore/deprecate.h +++ b/MagickCore/deprecate.h @@ -32,6 +32,10 @@ typedef int extern MagickExport MagickBooleanType GetMagickSeekableStream(const MagickInfo *); +extern MagickExport void + *CropImageToHBITMAP(Image *,const RectangleInfo *,ExceptionInfo *), + *ImageToHBITMAP(Image *,ExceptionInfo *); + #endif #if defined(__cplusplus) || defined(c_plusplus) diff --git a/MagickCore/nt-feature.c b/MagickCore/nt-feature.c index a8ca74ab5..fbaa2c22d 100644 --- a/MagickCore/nt-feature.c +++ b/MagickCore/nt-feature.c @@ -70,162 +70,6 @@ % % % % % % -% C r o p I m a g e T o H B i t m a p % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% CropImageToHBITMAP() extracts a specified region of the image and returns -% it as a Windows HBITMAP. While the same functionality can be accomplished by -% invoking CropImage() followed by ImageToHBITMAP(), this method is more -% efficient since it copies pixels directly to the HBITMAP. -% -% The format of the CropImageToHBITMAP method is: -% -% HBITMAP CropImageToHBITMAP(Image* image,const RectangleInfo *geometry, -% ExceptionInfo *exception) -% -% A description of each parameter follows: -% -% o image: the image. -% -% o geometry: Define the region of the image to crop with members -% x, y, width, and height. -% -% o exception: return any errors or warnings in this structure. -% -*/ -MagickExport void *CropImageToHBITMAP(Image *image, - const RectangleInfo *geometry,ExceptionInfo *exception) -{ -#define CropImageTag "Crop/Image" - - BITMAP - bitmap; - - HBITMAP - bitmapH; - - HANDLE - bitmap_bitsH; - - MagickBooleanType - proceed; - - RectangleInfo - page; - - register const Quantum - *p; - - register RGBQUAD - *q; - - RGBQUAD - *bitmap_bits; - - ssize_t - y; - - /* - Check crop geometry. - */ - assert(image != (const Image *) NULL); - assert(image->signature == MagickCoreSignature); - if (image->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); - assert(geometry != (const RectangleInfo *) NULL); - assert(exception != (ExceptionInfo *) NULL); - assert(exception->signature == MagickCoreSignature); - if (((geometry->x+(ssize_t) geometry->width) < 0) || - ((geometry->y+(ssize_t) geometry->height) < 0) || - (geometry->x >= (ssize_t) image->columns) || - (geometry->y >= (ssize_t) image->rows)) - ThrowImageException(OptionError,"GeometryDoesNotContainImage"); - page=(*geometry); - if ((page.x+(ssize_t) page.width) > (ssize_t) image->columns) - page.width=image->columns-page.x; - if ((page.y+(ssize_t) page.height) > (ssize_t) image->rows) - page.height=image->rows-page.y; - if (page.x < 0) - { - page.width+=page.x; - page.x=0; - } - if (page.y < 0) - { - page.height+=page.y; - page.y=0; - } - - if ((page.width == 0) || (page.height == 0)) - ThrowImageException(OptionError,"GeometryDimensionsAreZero"); - /* - Initialize crop image attributes. - */ - bitmap.bmType = 0; - bitmap.bmWidth = (LONG) page.width; - bitmap.bmHeight = (LONG) page.height; - bitmap.bmWidthBytes = bitmap.bmWidth * 4; - bitmap.bmPlanes = 1; - bitmap.bmBitsPixel = 32; - bitmap.bmBits = NULL; - - bitmap_bitsH=(HANDLE) GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,page.width* - page.height*bitmap.bmBitsPixel); - if (bitmap_bitsH == NULL) - return(NULL); - bitmap_bits=(RGBQUAD *) GlobalLock((HGLOBAL) bitmap_bitsH); - if ( bitmap.bmBits == NULL ) - bitmap.bmBits = bitmap_bits; - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - SetImageColorspace(image,sRGBColorspace,exception); - /* - Extract crop image. - */ - q=bitmap_bits; - for (y=0; y < (ssize_t) page.height; y++) - { - register ssize_t - x; - - p=GetVirtualPixels(image,page.x,page.y+y,page.width,1,exception); - if (p == (const Quantum *) NULL) - break; - - /* Transfer pixels, scaling to Quantum */ - for( x=(ssize_t) page.width ; x> 0 ; x-- ) - { - q->rgbRed = ScaleQuantumToChar(GetPixelRed(image,p)); - q->rgbGreen = ScaleQuantumToChar(GetPixelGreen(image,p)); - q->rgbBlue = ScaleQuantumToChar(GetPixelBlue(image,p)); - q->rgbReserved = 0; - p+=GetPixelChannels(image); - q++; - } - proceed=SetImageProgress(image,CropImageTag,y,page.height); - if (proceed == MagickFalse) - break; - } - if (y < (ssize_t) page.height) - { - GlobalUnlock((HGLOBAL) bitmap_bitsH); - GlobalFree((HGLOBAL) bitmap_bitsH); - return((void *) NULL); - } - bitmap.bmBits=bitmap_bits; - bitmapH=CreateBitmapIndirect(&bitmap); - GlobalUnlock((HGLOBAL) bitmap_bitsH); - GlobalFree((HGLOBAL) bitmap_bitsH); - return((void *) bitmapH); -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % % I s M a g i c k C o n f l i c t % % % % % @@ -547,113 +391,4 @@ MagickExport MagickBooleanType NTAcquireTypeCache(SplayTreeInfo *type_cache, return(MagickTrue); } -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % -% I m a g e T o H B i t m a p % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% ImageToHBITMAP() creates a Windows HBITMAP from an image. -% -% The format of the ImageToHBITMAP method is: -% -% HBITMAP ImageToHBITMAP(Image *image,Exceptioninfo *exception) -% -% A description of each parameter follows: -% -% o image: the image to convert. -% -*/ -MagickExport void *ImageToHBITMAP(Image *image,ExceptionInfo *exception) -{ - BITMAP - bitmap; - - HANDLE - bitmap_bitsH; - - HBITMAP - bitmapH; - - register ssize_t - x; - - register const Quantum - *p; - - register RGBQUAD - *q; - - RGBQUAD - *bitmap_bits; - - size_t - length; - - ssize_t - y; - - (void) memset(&bitmap,0,sizeof(bitmap)); - bitmap.bmType=0; - bitmap.bmWidth=(LONG) image->columns; - bitmap.bmHeight=(LONG) image->rows; - bitmap.bmWidthBytes=4*bitmap.bmWidth; - bitmap.bmPlanes=1; - bitmap.bmBitsPixel=32; - bitmap.bmBits=NULL; - length=bitmap.bmWidthBytes*bitmap.bmHeight; - bitmap_bitsH=(HANDLE) GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,length); - if (bitmap_bitsH == NULL) - { - char - *message; - - message=GetExceptionMessage(errno); - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'",message); - message=DestroyString(message); - return(NULL); - } - bitmap_bits=(RGBQUAD *) GlobalLock((HGLOBAL) bitmap_bitsH); - q=bitmap_bits; - if (bitmap.bmBits == NULL) - bitmap.bmBits=bitmap_bits; - (void) SetImageColorspace(image,sRGBColorspace,exception); - for (y=0; y < (ssize_t) image->rows; y++) - { - p=GetVirtualPixels(image,0,y,image->columns,1,exception); - if (p == (const Quantum *) NULL) - break; - for (x=0; x < (ssize_t) image->columns; x++) - { - q->rgbRed=ScaleQuantumToChar(GetPixelRed(image,p)); - q->rgbGreen=ScaleQuantumToChar(GetPixelGreen(image,p)); - q->rgbBlue=ScaleQuantumToChar(GetPixelBlue(image,p)); - q->rgbReserved=0; - p+=GetPixelChannels(image); - q++; - } - } - bitmap.bmBits=bitmap_bits; - bitmapH=CreateBitmapIndirect(&bitmap); - if (bitmapH == NULL) - { - char - *message; - - message=GetExceptionMessage(errno); - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'",message); - message=DestroyString(message); - } - GlobalUnlock((HGLOBAL) bitmap_bitsH); - GlobalFree((HGLOBAL) bitmap_bitsH); - return((void *) bitmapH); -} - #endif diff --git a/MagickCore/nt-feature.h b/MagickCore/nt-feature.h index 595c82ac0..1a877fcdc 100644 --- a/MagickCore/nt-feature.h +++ b/MagickCore/nt-feature.h @@ -26,10 +26,6 @@ extern "C" { #endif -extern MagickExport void - *CropImageToHBITMAP(Image *,const RectangleInfo *,ExceptionInfo *), - *ImageToHBITMAP(Image *,ExceptionInfo *); - #if !defined(XS_VERSION) extern MagickExport MagickBooleanType -- 2.40.0