I’ve got a small Class that takes a JSON String of points of a shape (from Adobe Illustrator) and generates a Picture from it…
I’ve been using this for a while in a Desktop app. Now I have a need to use this in a web app - but it doesn’t work.
It compiles, no errors.
However, when I step through the code to the bit where the GraphicsPath is filled on the Picture - nothing happens, inspecting the picture in the IDE and it’s blank.
Is there some restriction on what you can use in a web app when it comes to Pictures / GraphicsPath etc? As I said, it compiles OK, so you’d expect it to work.
I’ve also checked that the code previous to this that parses the JSON array is retrieving its values correctly, it is.
I’m not a Web expert but I know that console graphics is considerably different than desktop graphics. You might have to use something like ImageMagic from MBS to get it to work properly in console/web apps.
No Michel, I’m inspecting the picture in the IDE, stepping through the code line by line… the picture ends up with no content. But for info, yes, I’ve converted the empty picture to a webPicture and got an empty webPicture. Sorry.
thePath = New GraphicsPath // <- class property
Var shapeJSON As New JSONItem
shapeJSON.Load(tickShapeJSON) // < valid JSON array of points to add to thePath
Var pathPointsArrayJSON As JSONItem = shapeJSON.Value("pathPoints")
Var maxX, maxY As Double
For i As Integer = 0 To pathPointsArrayJSON.Count-1
Var thisPathPointJSON As JSONItem = pathPointsArrayJSON.ValueAt(i)
Var anchorJSON As JSONItem = thisPathPointJSON.Value("anchor")
Var leftDirectionJSON As JSONItem = thisPathPointJSON.Value("leftDirection")
Var rightDirectionJSON As JSONItem = thisPathPointJSON.Value("rightDirection")
Var x, y, cp1x, cp1y, cp2x, cp2y As Double
x = anchorJSON.ValueAt(0)
y = anchorJSON.ValueAt(1)
cp1x = leftDirectionJSON.ValueAt(0)
cp1y = leftDirectionJSON.ValueAt(1)
cp2x = rightDirectionJSON.ValueAt(0)
cp2y = rightDirectionJSON.ValueAt(1)
If i = 0 Then thePath.MoveToPoint(x,y)
x = Abs(x)
y = Abs(y)
cp1x = Abs(cp1x)
cp1y = Abs(cp1y)
cp2x = Abs(cp2x)
cp2y = Abs(cp2y)
If x > maxX Then maxX = x
If y > maxY Then maxY = y
thePath.AddCurveToPoint(x,y,cp1x,cp1y,cp2x,cp2y)
#If DebugBuild Then // <- make sure values coming from JSON array are OK
System.DebugLog i.ToString("#") + " x=" + x.ToString("#") + " y=" + y.ToString("#") + " cp1x=" + cp1x.ToString("#") + " cp1y=" + cp1y.ToString("#") + " cp2x=" + cp2x.ToString("#") + " cp2y=" + cp2y.ToString("#")
#EndIf
Next
Var basePic As New Picture(maxX+6,maxY+6)
basePic.Graphics.DrawingColor = myDrawingColor // <- class property
basePic.Graphics.FillPath thePath, True
Break
At the break point, I inspect ‘basePic’ and find it’s empty.
Could you draw something else to BasePic, for instance a rectangle or oval with graphics.drawrectangle for instance, just to see if the problem is with fillpath.
Absolutely Michel, just the .fillPath and .drawPath that don’t seem to do anything. I’ve submitted a bug report and the status has changed to “reproducible”.
It’s a long shot, but if Linux desktop does not have the bug (admitting you app runs under Linux), you could use a small windowless desktop helper to generate the picture. You can send it to the web app with IPCSocket. Since IPCSocket sends strings, you will have to encodebase64.