Recipe 17.7. Getting and Setting a Transparent Color17.7.2. ProblemYou want 17.7.3. SolutionUse $color = ImageColorAllocate($image, $red, $green, $blue); 17.7.4. DiscussionBoth GIFs and PNGs support transparencies; JPEGs, however, do not. To refer to the transparent color within GD, use the constant IMG_COLOR_TRANSPARENT. For example, here's how to make a dashed line that alternates between black and transparent: // make a two-pixel thick black and white dashed line To find the current transparency setting, take the return value of ImageColorTransparent( ) and pass it to ImageColorsForIndex( ): $transparent = ImageColorsForIndex($image, ImageColorTransparent($image)); The ImageColorsForIndex( ) function returns an array with the red, green, and blue values. In this case, the transparent color is white. 17.7.5. See AlsoDocumentation on ImageColorTransparent( ) at http://www.php.net/imagecolortransparent and on ImageColorsForIndex( ) at http://www.php.net/imagecolorsforindex. |
Tuesday, January 19, 2010
Recipe 17.7. Getting and Setting a Transparent Color
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment