Re: cvs: php-src(PHP_5_2) /ext/gd config.w32 gd.c php_gd.h
| From: | Marcus Boerger | Date: | Tue, 17 Apr 2007 17:29:16 +0000 |
| Subject: | Re: cvs: php-src(PHP_5_2) /ext/gd config.w32 gd.c php_gd.h | ||
| References: | 1 | Groups: | php.cvs php.doc |
| Request: | Send a blank email to phpdoc+get-969376085@lists.php.net to get a copy of this message | ||
Hello Pierre-Alain,
since when are we adding major new features to release branches?
best regards
marcus
Tuesday, April 17, 2007, 5:31:45 PM, you wrote:
> pajoye Tue Apr 17 15:31:45 2007 UTC
> Modified files: (Branch: PHP_5_2)
> /php-src/ext/gd config.w32 gd.c php_gd.h
> Log:
> - MFH: add imagegrabwindow and imagegrabscreen (win32 only) [DOC]
> capture a window using its handle or a full screen
>
>
> http://cvs.php.net/viewvc.cgi/php-src/ext/gd/config.w32?r1=1.10.4.3&r2=1.10.4.4&diff_format=u
> Index: php-src/ext/gd/config.w32
> diff -u php-src/ext/gd/config.w32:1.10.4.3 php-src/ext/gd/config.w32:1.10.4.4
> --- php-src/ext/gd/config.w32:1.10.4.3 Wed Apr 11 11:44:20 2007
> +++ php-src/ext/gd/config.w32 Tue Apr 17 15:31:45 2007
> @@ -1,4 +1,4 @@
> -// $Id: config.w32,v 1.10.4.3 2007/04/11 11:44:20 pajoye Exp $
> +// $Id: config.w32,v 1.10.4.4 2007/04/17 15:31:45 pajoye Exp $
> // vim:ft=javascript
>
> ARG_WITH("gd", "Bundled GD support", "yes,shared");
> @@ -24,6 +24,9 @@
> CHECK_LIB("zlib.lib", "gd", PHP_GD);
> }
>
> + CHECK_LIB("User32.lib", "gd", PHP_GD);
> + CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
> +
> EXTENSION("gd", "gd.c gdttf.c", null,
> "-Iext/gd/libgd", "php_gd2.dll");
> ADD_SOURCES("ext/gd/libgd", "gd2copypal.c gd_arc_f_buggy.c gd.c
> \
> gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
>
> http://cvs.php.net/viewvc.cgi/php-src/ext/gd/gd.c?r1=1.312.2.20.2.20&r2=1.312.2.20.2.21&diff_format=u
> Index: php-src/ext/gd/gd.c
> diff -u php-src/ext/gd/gd.c:1.312.2.20.2.20 php-src/ext/gd/gd.c:1.312.2.20.2.21
> --- php-src/ext/gd/gd.c:1.312.2.20.2.20 Fri Apr 6 15:38:35 2007
> +++ php-src/ext/gd/gd.c Tue Apr 17 15:31:45 2007
> @@ -18,7 +18,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: gd.c,v 1.312.2.20.2.20 2007/04/06 15:38:35 pajoye Exp $ */
> +/* $Id: gd.c,v 1.312.2.20.2.21 2007/04/17 15:31:45 pajoye Exp $ */
>
> /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
> Cold Spring Harbor Labs. */
> @@ -52,6 +52,9 @@
> #ifdef PHP_WIN32
> # include <io.h>
> # include <fcntl.h>
> +#include <windows.h>
> +#include <Winuser.h>
> +#include <Wingdi.h>
> #endif
>
> #if HAVE_LIBGD
> @@ -314,6 +317,18 @@
> ZEND_END_ARG_INFO()
> #endif
>
> +#ifdef PHP_WIN32
> +static
> +ZEND_BEGIN_ARG_INFO(arginfo_imagegrabwindow, 0, 0, 1)
> + ZEND_ARG_INFO(0, handle)
> + ZEND_ARG_INFO(0, client_area)
> +ZEND_END_ARG_INFO()
> +
> +static
> +ZEND_BEGIN_ARG_INFO(arginfo_imagegrabscreen, 0)
> +ZEND_END_ARG_INFO()
> +#endif
> +
> #ifdef HAVE_GD_BUNDLED
> static
> ZEND_BEGIN_ARG_INFO_EX(arginfo_imagerotate, 0, 0, 3)
> @@ -1020,6 +1035,11 @@
> PHP_FE(imagecopyresampled,
> arginfo_imagecopyresampled)
> #endif
>
> +#ifdef PHP_WIN32
> + PHP_FE(imagegrabwindow,
> arginfo_imagegrabwindow)
> + PHP_FE(imagegrabscreen,
> arginfo_imagegrabscreen)
> +#endif
> +
> #ifdef HAVE_GD_BUNDLED
> PHP_FE(imagerotate, arginfo_imagerotate)
> PHP_FE(imageantialias,
> arginfo_imageantialias)
> @@ -2069,6 +2089,155 @@
> /* }}} */
> #endif
>
> +#ifdef PHP_WIN32
> +/* {{{ proto resource imagegrabwindow(int window_handle [, int client_area])
> + Grab a window or its client area using a windows handle (HWND property in COM instance) */
> +PHP_FUNCTION(imagegrabwindow)
> +{
> + HWND window;
> + long client_area = 0;
> + RECT rc = {0};
> + RECT rc_win = {0};
> + int Width, Height;
> + HDC hdc;
> + HDC memDC;
> + HBITMAP memBM;
> + HBITMAP hOld;
> + HINSTANCE handle;
> + long lwindow_handle;
> + typedef BOOL (WINAPI *tPrintWindow)(HWND, HDC,UINT);
> + tPrintWindow pPrintWindow = 0;
> + gdImagePtr im;
> +
> + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l",
> &lwindow_handle, &client_area) == FAILURE) {
> + RETURN_FALSE;
> + }
> +
> + window = (HWND) lwindow_handle;
> +
> + if (!IsWindow(window)) {
> + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid window handle");
> + RETURN_FALSE;
> + }
> +
> + hdc = GetDC(0);
> +
> + if (client_area) {
> + GetClientRect(window, &rc);
> + Width = rc.right;
> + Height = rc.bottom;
> + } else {
> + GetWindowRect(window, &rc);
> + Width = rc.right - rc.left;
> + Height = rc.bottom - rc.top;
> + }
> +
> + Width = (Width/4)*4;
> +
> + memDC = CreateCompatibleDC(hdc);
> + memBM = CreateCompatibleBitmap(hdc, Width, Height);
> + hOld = (HBITMAP) SelectObject (memDC, memBM);
> +
> +
> + handle = LoadLibrary("User32.dll");
> + if ( handle == 0 ) {
> + goto clean;
> + }
> + pPrintWindow = (tPrintWindow) GetProcAddress(handle, "PrintWindow");
> +
> + if ( pPrintWindow ) {
> + pPrintWindow(window, memDC, (UINT) client_area);
> + } else {
> + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Windows API too old");
> + RETURN_FALSE;
> + goto clean;
> + }
> +
> + FreeLibrary(handle);
> +
> + im = gdImageCreateTrueColor(Width, Height);
> + if (im) {
> + int x,y;
> + for (y=0; y <= Height; y++) {
> + for (x=0; x <= Width; x++) {
> + int c = GetPixel(memDC, x,y);
> + gdImageSetPixel(im, x, y,
> gdTrueColor(GetRValue(c), GetGValue(c), GetBValue(c)));
> + }
> + }
> + }
> +
> +clean:
> + SelectObject(memDC,hOld);
> + DeleteObject(memBM);
> + DeleteDC(memDC);
> + ReleaseDC( 0, hdc );
> +
> + if (!im) {
> + RETURN_FALSE;
> + } else {
> + ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
> + }
> +}
> +/* }}} */
> +
> +/* {{{ proto resource imagegrabscreen(int window_handle [, int client_area])
> + Grab a screenshot */
> +PHP_FUNCTION(imagegrabscreen)
> +{
> + HWND window = GetDesktopWindow();
> + RECT rc = {0};
> + int Width, Height;
> + HDC hdc;
> + HDC memDC;
> + HBITMAP memBM;
> + HBITMAP hOld;
> + HINSTANCE handle;
> + long lwindow_handle;
> + typedef BOOL (WINAPI *tPrintWindow)(HWND, HDC,UINT);
> + tPrintWindow pPrintWindow = 0;
> + gdImagePtr im;
> + hdc = GetDC(0);
> +
> + if (!hdc) {
> + RETURN_FALSE;
> + }
> +
> + GetWindowRect(window, &rc);
> + Width = rc.right - rc.left;
> + Height = rc.bottom - rc.top;
> +
> + Width = (Width/4)*4;
> +
> + memDC = CreateCompatibleDC(hdc);
> + memBM = CreateCompatibleBitmap(hdc, Width, Height);
> + hOld = (HBITMAP) SelectObject (memDC, memBM);
> + BitBlt( memDC, 0, 0, Width, Height , hdc, rc.left, rc.top , SRCCOPY );
> +
> + im = gdImageCreateTrueColor(Width, Height);
> + if (im) {
> + int x,y;
> + for (y=0; y <= Height; y++) {
> + for (x=0; x <= Width; x++) {
> + int c = GetPixel(memDC, x,y);
> + gdImageSetPixel(im, x, y,
> gdTrueColor(GetRValue(c), GetGValue(c), GetBValue(c)));
> + }
> + }
> + }
> +
> + SelectObject(memDC,hOld);
> + DeleteObject(memBM);
> + DeleteDC(memDC);
> + ReleaseDC( 0, hdc );
> +
> + if (!im) {
> + RETURN_FALSE;
> + } else {
> + ZEND_REGISTER_RESOURCE(return_value, im, le_gd);
> + }
> +}
> +/* }}} */
> +#endif PHP_WIN32
> +
> #ifdef HAVE_GD_BUNDLED
> /* {{{ proto resource imagerotate(resource src_im, float angle, int bgdcolor [, int
> ignoretransparent])
> Rotate an image using a custom angle */
>
> http://cvs.php.net/viewvc.cgi/php-src/ext/gd/php_gd.h?r1=1.59.2.3.2.4&r2=1.59.2.3.2.5&diff_format=u
> Index: php-src/ext/gd/php_gd.h
> diff -u php-src/ext/gd/php_gd.h:1.59.2.3.2.4 php-src/ext/gd/php_gd.h:1.59.2.3.2.5
> --- php-src/ext/gd/php_gd.h:1.59.2.3.2.4 Wed Apr 4 01:58:24 2007
> +++ php-src/ext/gd/php_gd.h Tue Apr 17 15:31:45 2007
> @@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: php_gd.h,v 1.59.2.3.2.4 2007/04/04 01:58:24 pajoye Exp $ */
> +/* $Id: php_gd.h,v 1.59.2.3.2.5 2007/04/17 15:31:45 pajoye Exp $ */
>
> #ifndef PHP_GD_H
> #define PHP_GD_H
> @@ -114,6 +114,11 @@
> PHP_FUNCTION(imagecopyresampled);
> #endif
>
> +#ifdef PHP_WIN32
> +PHP_FUNCTION(imagegrabwindow);
> +PHP_FUNCTION(imagegrabscreen);
> +#endif
> +
> #ifdef HAVE_GD_BUNDLED
> PHP_FUNCTION(imagerotate);
> PHP_FUNCTION(imageantialias);
Best regards,
Marcus