Adobe COLDFUSION 9 Manual page 976

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
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:
Task
Resize an image
Resize images so that they fit in a defined square or rectangle and
control the interpolation method
Resize an image and control the interpolation method
Using the cfimage tag resize action
Use the
tag
cfimage
resize
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.
action to resize an image to the specified height and width. You can specify the height
Last updated 8/5/2010
Functions and actions
function, or the
ImageResize
resize
ImageScaleToFit
function
function
ImageResize
action of the
tag
cfimage
971

Advertisement

Table of Contents
loading

Table of Contents