BTW...sorry i am not threading this properly as I download my email on my
personal computer, and read ti there normally, but this is being sent via a
web interface from work..

Where I am at:  I have it so that the banner is getting the proper
width...now to figure out the vertical centering issue...

<cfcomponent
    output="false"
    hint="Image utility functions that abstract out complex ColdFusion image
manipulation processes.">
    <cffunction name="img_create_banner" access="public" output="true"
returntype="Any"
            hint="Creates banner grapic with custom text">
        <cfargument name = "text"      type = "string" required="true">
        <cfargument name = "fontname"      type = "string" required="true">
        <cfargument name = "style"      type = "string" required="true"
hint="Must be Plain, Bold, Italics, or Bolditalics">
        <cfargument name = "size"      type = "string" required="true">
        <cfargument name = "color"      type = "string" required="true"
hint="hex value with put pound sign">
        <cfargument name = "bgcolor" type = "string" required="true"
hint="hex value with put pound sign">
        <cfargument name = "path"      type = "string" required="true">
        <cfargument name = "name"      type = "string" required="true">
        <cfargument name = "xOffsetVal" type = "any"    required="true">
        <cfargument name = "yOffsetVal" type = "any"    required="true">
        <cfscript>
            Font = CreateObject("java", "java.awt.Font");
            variables.color="##"&arguments.color;
            variables.bgcolor="##"&arguments.bgcolor;
            variables.style=arguments.style;
            variables.fontname="#trim(arguments.fontname)#";
            variables.text={x=10, y=30, string=arguments.text};
            variables.text.prop={font = variables.fontname,
Size=arguments.size, style=variables.style, javaStyle= BitOr(Font.BOLD,
Font.ITALIC), txtColor=variables.color, bgColor=variables.bgcolor};
            //variables.text =  { x = 10, y = 30, string = arguments.text
};
           // variables.text.prop = { font_name="LunaITC TT",
style=arguments.style, javaStyle= BitOr(Font.BOLD, Font.ITALIC),
size=arguments.size, txtColor=variables.color,
bgcolor=variables.bgColor};
               //writedump(variables.text.prop);
            param name="arguments.xOffsetVal" default=0;
            param name="arguments.yOffsetVal" default=0;
            variables.offsetVal={x=arguments.xOffsetVal,
y=arguments.yOffsetVal};
            variables.imageOffset={x=20, y=10};
            //strObject=createObject("java","java.lang.String");
            //strTemp="#UCase(arguments.text)#";
            //isAllCaps=compare(strTemp,arguments.text);
            // initialize the text properties
             // create a new image and draw the text

            img = ImageNew("", 10, 30, "rgb", arguments.bgcolor );
            // get the underlying graphic of the image
            graphics = ImageGetBufferedImage( img ).getGraphics();
         </cfscript>
        <!---  <br><cfdump var="#variables.text#"><br> --->
         <!--- Check for a defined style. --->
         <cfswitch expression="#variables.text.prop.style#">
               <cfcase value="Bold">
                   <cfset variables.text.prop.javastyle = Font.BOLD>
            </cfcase>
            <cfcase value="Italic">
                   <cfset variables.text.prop.javastyle = Font.ITALIC>
            </cfcase>
            <cfcase value="BoldItalic">
                  <cfset variables.text.prop.javastyle =
BitOR(Font.BOLD,Font.ITALIC)>
            </cfcase>
            <!--- Otherwise, just use the default PLAIN style --->
            <cfdefaultcase>
                <cfset variables.text.prop.javastyle = Font.PLAIN>
            </cfdefaultcase>
          </cfswitch>
          <cfscript>
               // recreate the font used to draw the text
            CurrentFont = Font.init( javacast("string",
variables.text.prop.font),
            javacast("int", variables.text.prop.javaStyle),
            javacast("int", variables.text.prop.size)         );
            // get text measurements using font metrics
            fontMetrics = graphics.getFontMetrics( CurrentFont );
            fontBounds = fontMetrics.getStringBounds( javacast("string",
variables.text.string), graphics );
            img = ImageNew("", fontBounds.getWidth()+20,
fontBounds.getHeight()+10, "rgb", variables.text.prop.bgcolor);
            graphics = ImageGetBufferedImage( img ).getGraphics();
            //graphics.setColor(variables.text.prop.bgcolor);
            ImageSetDrawingColor( img, variables.text.prop.txtColor );
            variables.OffsetVal.y=  javacast("int", variables.text.y)/2 +
javacast("int",(fontBounds.getHeight())/2)+variables.OffsetVal.y ;
            variables.offsetVal.x=variables.text.x+variables.OffsetVal.x;
            ImageDrawText( img,
variables.text.string,variables.OffsetVal.x,variables.OffsetVal.y ,
variables.text.prop );
            // draw a rectangle indicatating the font bounds
           //graphics.setColor(variables.text.prop.bgcolor);
            //ImageSetDrawingColor( img, variables.text.prop.bgColor );
            //graphics.drawRect(
            //    javacast("int", variables.text.x)-5,
            //    javacast("int", variables.text.y) -
fontMetrics.getAscent()-5,
            //    fontBounds.getWidth()+10,
            //    fontBounds.getHeight()+10        );
            // get the dimensions
            dimensions.xoffset=variables.OffsetVal.x;
            dimensions.yoffset=variables.OffsetVal.y;
            dimensions.type = "FontMetrics";
            dimensions.width = fontBounds.getWidth();
            dimensions.height = fontBounds.getHeight();
            dimensions.height_int = javacast("int",fontBounds.getHeight());

            dimensions.leading = fontMetrics.getLeading();
            dimensions.ascent = fontMetrics.getAscent();
            dimensions.descent = fontMetrics.getDescent();
            graphics.dispose();
        </cfscript>
        <!--- <cfdump var="#dimensions#"> --->
        <!--- <cfimage action="writeToBrowser" source="#img#">   --->
        <cfimage action="write" source="#img#" destination="#path#/#name#"
overwrite="true">

    </cffunction>
</cfcomponent>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337072
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to