gd_rotate . gd . sncode
GD_ROTATE(1e)
NAME
gd_rotate - Rotates a GD image.
SYNOPSIS
gd_rotate (gdsrc:variable, gddst:variable, srcx:integer, srcy:integer, srcw:integer, srch:integer, dstx:integer,dsty:integer,dstw:integer,dsth:integer,angle:integer, transparent:"string", bgcolor:"string",pourc:float, truecolor:true|false);
DESCRIPTION
This function is used to rotate a GD image.
gd_rotate really creates a new image if gddst is not specified, so it returns the new GD structure. The old GD structure is still valid. gd_free must be call with this new GD structure.
pourc and dw,dh are mutually exclusive.
The srcX and srcY coordinates specify the upper left corner of the source area; however, the dstX and dstY coordinates specify the CENTER of the destination area. This important distinction is made because the rotated rectangle may may or may not be parallel to the X and Y axes. The destination coordinates may be floating point, as the center of the desired destination area may lie at the center of a pixel (0.5 pixels) rather than its upper left corner. The angle specified is an integer number of degrees, between 0 and 360, with 0 degrees causing no change, and counterclockwise rotation as the angle increases.
PARAMETERS
- srcx,srcy
- Initial coordinates in the source image.
- srcw,srch
- Width and Height or source image.
- dstx,dsty
- Initial coordinates in the destination image.
- dstw,dsth
- Width and Height in the destination image.
- pourc
- Resizes image width this pourcentage.
- gdsrc
- Variable must hold a return value from gd_new.
- angle
- Angle to rotate 0 to 360.
- gddst
- Variable must hold a returned value from gd_new. If this is not specified, a new image is created.
- truecolor
- truecolor, tells new() to create a truecolor GD::Image object. Truecolor images have 24 bits of color data (eight bits each in the red, green and blue channels respectively), allowing for precise photograph-quality color usage. If not specified, the image will use an 8-bit palette for compatibility with older versions of libgd.
- transparent
- Specifies transparent color. Transparent color can be specify as bgcolor to use the backgound color. A color is specified as "#XXXXX" or as "255,255,255". Note that JPEG images do not support transparency, so this setting has no effect when writing JPEG images.
- bgcolor
- Specifies background color. A color is specified as "#XXXXX" or as "255,255,255".
RETURN
- A pointer to the new GD structure. Will be used in other functions.
MODULES
To use this module, you must specify the following in /usr/local/website/site.conf:
Module gd { Library : "/usr/local/lib/libsngd.so" Init : "sngd_init" }
EXAMPLES
res=<{ %include "/includes/gd.sn"; remove("/html/images/rot1.jpg"); remove("/html/images/rot2.jpg"); imsrc=gd_new(filename:"/html/images/20130708-1944-londres.jpg",truecolor:true); imdst=gd_new(width:1000,height:1000,bgcolor:Blue,truecolor:true); gd_rotate(gdsrc:imsrc, gddst:imdst,srcx:400,srcy:400,srcw:800,srch:800,dstx:50,dsty:50,angle:45); gd_write(gd:imsrc,format:"jpg",filename:"/html/images/rot1.jpg"); gd_write(gd:imdst,format:"jpg",filename:"/html/images/rot2.jpg",quality:100); gd_free(imsrc); gd_free(imdst); -e "/html/images/rot1.jpg"; -e "/html/images/rot2.jpg"; }>.), q(res=truetrue.),{asm=>"-a"});
AUTHOR
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>