From cec88095a8a8a2011c7f7e248b71b1a63e50371b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 8 Nov 2012 12:57:11 +0000 Subject: [PATCH] 2012-11-08 13:55 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbgd/doc/en/hbgd.txt * contrib/hbgd/gdimage.prg * cleanups related to no longer needed "destroy" code * GDImage:Destory() method deprecated with HB_LEGACY_LEVEL4 --- harbour/ChangeLog | 6 ++++ harbour/contrib/hbgd/doc/en/hbgd.txt | 50 ++-------------------------- harbour/contrib/hbgd/gdimage.prg | 39 +++++++++------------- 3 files changed, 24 insertions(+), 71 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9426484afd..115f9f9d57 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,12 @@ The license applies to all entries newer than 2009-04-28. */ +2012-11-08 13:55 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbgd/doc/en/hbgd.txt + * contrib/hbgd/gdimage.prg + * cleanups related to no longer needed "destroy" code + * GDImage:Destory() method deprecated with HB_LEGACY_LEVEL4 + 2012-11-08 10:52 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/src/rtl/rat.c ! fixed HB_RAT() used with 3-rd and/or 4-th parameter and multibyte CPs diff --git a/harbour/contrib/hbgd/doc/en/hbgd.txt b/harbour/contrib/hbgd/doc/en/hbgd.txt index c9ce323649..4569f6baed 100644 --- a/harbour/contrib/hbgd/doc/en/hbgd.txt +++ b/harbour/contrib/hbgd/doc/en/hbgd.txt @@ -66,7 +66,6 @@ This image has no more than 256 colors. gdImageCreate() returns an image pointer or NIL if unable to create the image. - The image pointer must be destroyed using gdImageDestroy() $EXAMPLES$ PROCEDURE Main() @@ -105,7 +104,6 @@ This image has true colors. gdImageCreateTrueColor() returns an image pointer or NIL if unable to create the image. - The image pointer must be destroyed using gdImageDestroy() $EXAMPLES$ PROCEDURE Main() @@ -125,43 +123,6 @@ $END$ */ -/* $DOC$ - $FUNCNAME$ - gdImageDestroy() - $CATEGORY$ - HBGD - $ONELINER$ - Free memory used from an image. - $SYNTAX$ - gdImageDestroy( ) --> NIL - $ARGUMENTS$ - - Image pointer - $RETURNS$ - NIL - $DESCRIPTION$ - gdImageDestroy() frees memory used from an image. - It's important to use this function before exiting from a program. - - HBGD uses it's own memory to manage an image, so it is important to use this function. - - $EXAMPLES$ - PROCEDURE Main() - LOCAL pImage := gdImageCreateTrueColor( 64, 64 ) - - // Use image here - - RETURN - $STATUS$ - R - $COMPLIANCE$ - GD Library - $PLATFORMS$ - All - $SEEALSO$ - gdImageCreate(), gdImageCreateTrueColor() - $END$ - */ - /* $DOC$ $FUNCNAME$ gdImageFromJpeg() @@ -196,7 +157,6 @@ the pImage pointer returned will be not NIL if successfull and will contains a memory pointer to the jpeg image. - Remember to free memory with gdImageDestroy() before exit from application. HBGD uses it's own memory to manage an image, so it is important to use this function. $EXAMPLES$ @@ -251,7 +211,6 @@ the pImage pointer returned will be not NIL if successfull and will contains a memory pointer to the gif image. - Remember to free memory with gdImageDestroy() before exit from application. HBGD uses it's own memory to manage an image, so it is important to use this function. $EXAMPLES$ @@ -306,7 +265,6 @@ the pImage pointer returned will be not NIL if successfull and will contains a memory pointer to the png image. - Remember to free memory with gdImageDestroy() before exit from application. HBGD uses it's own memory to manage an image, so it is important to use this function. $EXAMPLES$ @@ -361,7 +319,6 @@ the pImage pointer returned will be not NIL if successfull and will contains a memory pointer to the GD image. - Remember to free memory with gdImageDestroy() before exit from application. HBGD uses it's own memory to manage an image, so it is important to use this function. $EXAMPLES$ @@ -416,7 +373,6 @@ the pImage pointer returned will be not NIL if successfull and will contains a memory pointer to the WBmp image. - Remember to free memory with gdImageDestroy() before exit from application. HBGD uses it's own memory to manage an image, so it is important to use this function. $EXAMPLES$ @@ -1584,8 +1540,7 @@ different brush images, you can quickly fill your color map, and the results will not be optimal. - You need not take any special action when you are finished with a brush. As for any other image, - if you will not be using the brush image for any further purpose, you should call gdImageDestroy. + You need not take any special action when you are finished with a brush. As for any other image. You must not use the color gdBrushed if the current brush has been destroyed; you can of course set a new brush to replace it. @@ -1657,8 +1612,7 @@ different tile images, you can quickly fill your color map, and the results will not be optimal. You need not take any special action when you are finished with a tile. As for any other - image, if you will not be using the tile image for any further purpose, you should call - gdImageDestroy. You must not use the color gdTiled if the current tile has been destroyed; + image. You must not use the color gdTiled if the current tile has been destroyed; you can of course set a new tile to replace it. $EXAMPLES$ diff --git a/harbour/contrib/hbgd/gdimage.prg b/harbour/contrib/hbgd/gdimage.prg index 8ee5b8acd2..1b726f4535 100644 --- a/harbour/contrib/hbgd/gdimage.prg +++ b/harbour/contrib/hbgd/gdimage.prg @@ -68,7 +68,6 @@ CREATE CLASS GDImage VAR aPoints INIT {} VAR aStyles INIT {} - VAR lDestroy INIT .T. EXPORTED: VAR hFile @@ -133,18 +132,19 @@ CREATE CLASS GDImage METHOD ToString() INLINE gdImageToString( Self ) +#if defined( HB_LEGACY_LEVEL4 ) // Destructor METHOD Destroy() DESTRUCTOR Destruct() - - +#endif /* DRAWING FUNCTIONS */ + METHOD SetPixel( x, y, color ) INLINE hb_default( @color, ::pColor ), gdImageSetPixel( ::pImage, x, y, color ) METHOD Line( x1, y1, x2, y2, color ) INLINE hb_default( @color, ::pColor ), gdImageLine( ::pImage, x1, y1, x2, y2, color ) METHOD DashedLine( x1, y1, x2, y2, color ) INLINE hb_default( @color, ::pColor ), gdImageDashedLine( ::pImage, x1, y1, x2, y2, color ) - // Functions usefull for polygons + // Functions useful for polygons METHOD Polygon( aPoints, lFilled, color ) METHOD OpenPolygon( aPoints, color ) METHOD AddPoint( x, y ) INLINE AAdd( ::aPoints, { x, y } ) @@ -180,6 +180,7 @@ CREATE CLASS GDImage METHOD SetClippingArea( x1, y1, x2, y2 ) INLINE gdImageSetClip( ::pImage, x1, y1, x2, y2 ) /* QUERY FUNCTIONS */ + METHOD ColorsTotal() INLINE gdImageColorsTotal( ::pImage ) METHOD Alpha( color ) INLINE hb_default( @color, ::pColor ), gdImageAlpha( ::pImage, color ) METHOD Red( color ) INLINE hb_default( @color, ::pColor ), gdImageRed( ::pImage, color ) @@ -243,6 +244,7 @@ CREATE CLASS GDImage gdImageFTSize( cString, cFontName, nPitch ) /* COLOR HANDLING FUNCTIONS */ + METHOD SetColor( r, g, b ) INLINE iif( PCount() == 2, ::pColor := r, ::pColor := gdImageColorAllocate( ::pImage, r, g, b ) ) METHOD DelColor( pColor ) INLINE ::pColor := NIL, gdImageColorDeAllocate( ::pImage, pColor ) METHOD SetColorAlpha( r, g, b, a ) INLINE ::pColor := gdImageColorAllocateAlpha( ::pImage, r, g, b, a) @@ -259,6 +261,7 @@ CREATE CLASS GDImage METHOD SetInterlaceOff() INLINE gdImageInterlace( ::pImage, .F. ) /* COPY AND RESIZING FUNCTIONS */ + METHOD Copy( nSrcX, nSrcY, nWidth, nHeight, nDstX, nDstY, oDestImage ) METHOD CopyResized( nSrcX, nSrcY, nSrcWidth, nSrcHeight, nDstX, nDstY, nDstWidth, nDstHeight, oDestImage ) METHOD CopyResampled( nSrcX, nSrcY, nSrcWidth, nSrcHeight, nDstX, nDstY, nDstWidth, nDstHeight, oDestImage ) @@ -297,9 +300,13 @@ METHOD New( sx, sy ) CLASS GDImage RETURN Self +#if defined( HB_LEGACY_LEVEL4 ) + METHOD PROCEDURE Destruct() CLASS GDImage RETURN +#endif + METHOD Polygon( aPoints, lFilled, color ) CLASS GDImage hb_default( @aPoints, ::aPoints ) @@ -369,10 +376,8 @@ METHOD LoadFromFile( cFile ) CLASS GDImage aLoad := gdImageFromFile( cFile ) // Self := aLoad[ 1 ]:Clone() - ::Destroy() Self := ::CloneDataFrom( aLoad[ 1 ] ) - // Self := __objClone( aLoad[1] ) - aLoad[ 1 ]:lDestroy := .F. + // Self := __objClone( aLoad[ 1 ] ) aLoad[ 1 ] := NIL ::hFile := aLoad[ 2 ] @@ -381,10 +386,14 @@ METHOD LoadFromFile( cFile ) CLASS GDImage RETURN Self +#if defined( HB_LEGACY_LEVEL4 ) + /* dummy. no longer needed */ METHOD Destroy() CLASS GDImage RETURN Self +#endif + METHOD Copy( nSrcX, nSrcY, nWidth, nHeight, nDstX, nDstY, oDestImage ) CLASS GDImage hb_default( @nSrcX , 0 ) @@ -574,13 +583,10 @@ METHOD Rotate( nAngle, lInside ) CLASS GDImage ELSE ::CopyRotated( ,,,,,, nAngle, oDestImage ) ENDIF - ::Destroy() Self := ::CloneDataFrom( oDestImage ) // Self := __ObjClone( oDestImage ) // non funziona // Move new image to existing one - // Signal that this image must not be destroyed - oDestImage:lDestroy := .F. oDestImage := NIL RETURN Self @@ -590,13 +596,10 @@ METHOD Crop( nX, nY, nWidth, nHeight ) CLASS GDImage LOCAL oDestImage oDestImage := ::CopyResized( nX, nY, nWidth, nHeight, 0, 0, nWidth, nHeight ) - ::Destroy() Self := ::CloneDataFrom( oDestImage ) // Self := __ObjClone( oDestImage ) // non funziona // Move new image to existing one - // Signal that this image must not be destroyed - oDestImage:lDestroy := .F. oDestImage := NIL RETURN Self @@ -606,13 +609,10 @@ METHOD Resize( nWidth, nHeight ) CLASS GDImage LOCAL oDestImage oDestImage := ::CopyResampled( 0, 0, NIL, NIL, 0, 0, nWidth, nHeight ) - ::Destroy() Self := ::CloneDataFrom( oDestImage ) // Self := __ObjClone( oDestImage ) // non funziona // Move new image to existing one - // Signal that this image must not be destroyed - oDestImage:lDestroy := .F. oDestImage := NIL RETURN Self @@ -622,13 +622,10 @@ METHOD Zoom( nPerc ) CLASS GDImage LOCAL oDestImage oDestImage := ::CopyZoomed( nPerc ) - ::Destroy() Self := ::CloneDataFrom( oDestImage ) // Self := __ObjClone( oDestImage ) // non funziona // Move new image to existing one - // Signal that this image must not be destroyed - oDestImage:lDestroy := .F. oDestImage := NIL RETURN Self @@ -650,10 +647,7 @@ METHOD Clone() CLASS GDImage oDestImage:pImage := pImage ::Copy( 0, 0, ::Width, ::Height, 0, 0, oDestImage ) - // pImage := oDestImage:pImage - // // Signal that this image must not be destroyed - // oDestImage:lDestroy := .F. // oDestImage := NIL // oDestImage:pImage := pImage @@ -729,7 +723,6 @@ METHOD CloneDataFrom( oSrc ) ::aPoints := AClone( oSrc:aPoints ) ::aStyles := AClone( oSrc:aStyles ) - ::lDestroy := oSrc:lDestroy ::hFile := oSrc:hFile ::cType := oSrc:cType