
971
DEVELOPING
COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
Las
t
upda
te
d 8/5/2010
Drawing controls apply to all subsequent drawing functions in an image; therefore, order is important. In the following
example, the drawing stroke attributes defined in the attribute collection apply to the square and the two lines.
Similarly, the color green applies to the rectangle and the square, while the color red applies only to the two lines. You
can reset a drawing control as many times as necessary within an image to achieve the desired effect.
<!--- Create an attribute collection for the drawing stroke. --->
<cfset attr=StructNew()>
<cfset attr.width="4">
<cfset attr.endcaps="round">
<cfset attr.dashPattern=ArrayNew(1)>
<cfset dashPattern[1]=8>
<cfset dashPattern[2]=6>
<cfset attr.dashArray=dashPattern>
<cfset myImage=ImageNew("",200,200)>
<cfset ImageDrawOval(myImage,40,20,100,100)>
<!--- Set the drawing color to green for all subsequent drawing functions. --->
<cfset ImageSetDrawingColor(myImage,"green")>
<cfset ImageDrawRect(myImage,70,50,40,20,true)>
<!--- Apply the attribute collection to all subsequent shapes and lines in the image. --->
<cfset ImageSetDrawingStroke(myImage,attr)>
<cfset ImageDrawRect(myImage,40,40,100,100)>
<!--- Set the drawing color to red for all subsequent drawing functions. --->
<cfset ImageSetDrawingColor(myImage,"red")>
<cfset ImageDrawLine(myImage,130,40,100,200)>
<cfset ImageDrawLine(myImage,50,40,100,200)>
<cfimage source="#myImage#" action="write" destination="testMyImage.gif" overwrite="yes">
<img src="testMyImage.gif"/>
Resizing images
ColdFusion makes it easy to resize images. You can reduce the file size of an image by changing its dimensions, enforce
uniform sizes on images, and create thumbnail images. The following table describes the ways to resize images in
ColdFusion:
Using the cfimage tag resize action
Use the
cfimage
tag
resize
action to resize an image to the specified height and width. You can specify the height
and width in pixels or as a percentage of the original dimensions of the image. To specify a percentage, include the
percent symbol (%) in the height and width definitions.
Task
Functions and actions
Resize an image
ImageResize
function, or the
resize
action of the
cfimage
tag
Resize images so that they fit in a defined square or rectangle and
control the interpolation method
ImageScaleToFit
function
Resize an image and control the interpolation method
ImageResize
function
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...