diff --git a/includes/image.inc b/includes/image.inc index a6e7ab9..e30a338 100644 --- a/includes/image.inc +++ b/includes/image.inc @@ -290,12 +290,12 @@ function image_resize(stdClass $image, $width, $height) { * An image object returned by image_load(). * @param $degrees * The number of (clockwise) degrees to rotate the image. - * @param int $background - * (optional) A 24 bit or 32 bit ARGB value specifying the background color - * to use for the uncovered area of the image after the rotation (for - * example, 0 for black, 16711935 for fuchsia, and 16777215 for white). For - * images that support transparency, this will default to transparent. - * Otherwise it will be white. + * @param $background + * An hexadecimal integer specifying the background color to use for the + * uncovered area of the image after the rotation. E.g. 0x000000 for black, + * 0xff00ff for magenta, and 0xffffff for white. For images that support + * transparency, this will default to transparent. Otherwise it will + * be white. * * @return * TRUE on success, FALSE on failure. @@ -431,23 +431,5 @@ function image_save(stdClass $image, $destination = NULL) { } /** - * Converts a 24 bit RGB or 32 bit ARGB value to an RGBA array. - * - * @param int $argb - * The color code to convert. - * - * @return array - * An array containing the values for 'red', 'green', 'blue', and 'alpha'. - */ -function image_dec_to_rgba($argb) { - return array( - 'red' => $argb >> 16 & 0xFF, - 'green' => $argb >> 8 & 0xFF, - 'blue' => $argb & 0xFF, - 'alpha' => $argb >> 24 & 0xFF, - ); -} - -/** * @} End of "defgroup image". */ diff --git a/modules/simpletest/tests/image.test b/modules/simpletest/tests/image.test index cb346c1..3b816f1 100644 --- a/modules/simpletest/tests/image.test +++ b/modules/simpletest/tests/image.test @@ -448,6 +448,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase { $correct_dimensions_object = TRUE; $correct_colors = TRUE; + // Check the real dimensions of the image first. if (imagesy($image->resource) != $values['height'] || imagesx($image->resource) != $values['width']) { $correct_dimensions_real = FALSE; } diff --git a/modules/system/image.gd.inc b/modules/system/image.gd.inc index 6552a37..3d0797e 100644 --- a/modules/system/image.gd.inc +++ b/modules/system/image.gd.inc @@ -98,12 +98,12 @@ function image_gd_resize(stdClass $image, $width, $height) { * $image->info['height'] values will be modified by this call. * @param $degrees * The number of (clockwise) degrees to rotate the image. - * @param int $background - * (optional) A 24 bit or 32 bit ARGB value specifying the background color - * to use for the uncovered area of the image after the rotation (for - * example, 0 for black, 16711935 for fuchsia, and 16777215 for white). For - * images that support transparency, this will default to transparent. - * Otherwise it will be white. + * @param $background + * An hexadecimal integer specifying the background color to use for the + * uncovered area of the image after the rotation. E.g. 0x000000 for black, + * 0xff00ff for magenta, and 0xffffff for white. For images that support + * transparency, this will default to transparent. Otherwise it will + * be white. * @return * TRUE or FALSE, based on success. * @@ -121,13 +121,23 @@ function image_gd_rotate(stdClass $image, $degrees, $background = NULL) { // angle to a positive one between 0 and 360 degrees. $degrees -= floor($degrees / 360) * 360; + // Convert the hexadecimal background value to a RGBA array. if (isset($background)) { - $background = image_dec_to_rgba($background); - $background['alpha'] = 0; + $background = array( + 'red' => $background >> 16 & 0xFF, + 'green' => $background >> 8 & 0xFF, + 'blue' => $background & 0xFF, + 'alpha' => 0, + ); } else { // Background color is not specified: use transparent white as background. - $background = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127); + $background = array( + 'red' => 255, + 'green' => 255, + 'blue' => 255, + 'alpha' => 127 + ); } // Store the color index for the background as that is what GD uses.