I've been playing around with imageDrawLine(s) and imageDrawText (only just recently discovered them), and I am confused about something that I hope someone can help clarify.
If I create a new image using imageNew, I can draw lines and text on it with no problems.
However, if I use CFIMAGE or imageNew to create an image from an existing .gif, it will not work. It does not error - it just leaves a blank white space where the image should be.
Is it not possible to add lines or text to existing images?? Here's my code, so far:
<cfimage action="read" source="#app_root#img/500x500.gif" name="myImage" />
<cfset imageSetAntiAliasing(myImage,'on') />
<cfset imageSetDrawingColor(myImage,'black') />
<cfset attr = StructNew() />
<cfset attr.width = 5 />
<cfset attr.endcaps = "round" />
<cfset imageSetDrawingStroke(myImage,attr) />
... set x/y arrays ...
<cfset imageDrawLInes(myImage,x,y,true,false) />
<cfimage action="writetobrowser" source="#myImage#" format="png" />
As the code above is, this gives me a blank square 500 x 500. No lines. No text, if I use the imageDrawText tag.
If I change line 01 to <cfset myImage = imageNew('','500','500','rgb','white') />, then it gives me a white square with the lines drawn as I coded for.
What I am doing incorrectly? Or does it not work with existing images?
Has ANYone used imageDrawLine or imageDrawText whom might be able to shed some light on my query?
I, finally, was able to gleam some information on this subject. Previous Google searches only showed how to line/text draw on newly created, blank images. After some cursing, and hair-pulling (my own, not anyone else), and shaking of fists at empty air while screaming at the gods of cyberspace, I did stumble across this.
It indicates that you _can_ draw on an existing image, although I haven't tried it, yet. I'm going to give this a shot, and I'll report how my experiment went.
Okay.. there is a bit of important information that I am not currently seeing in the instructions that would have been beneficial had I known about it from the get-go.
If you do not use imageSetDrawingColor(), then anything you write will not appear on the image. I don't know if it puts the text there and it's just transparent, or if it just plain doesn't put text or lines in place. But not setting the color before using the imageDrawText() tag will make it look like nothing is happening.
It is now working.