Hey guys,
In messing with a WebCanvas control, it seems to me that the WebCanvas wants to paint a picture that is a file on disk, not one in memory. If I have a picture in my project and paint that directly to my web canvas, it works fine. However, if I manipulate the picture in any way - scale it, resize it, etc. Then the canvas no longer paints the image.
So let’s take the Chart Example Xojo that is in the Examples included with Xojo. The first part of the paint event has code that looks like:
Dim LLx As Integer = 50
Dim LLy As Integer = g.Height-50
Dim LRx As Integer = g.Width-50
// White Background
g.ForeColor = &cFFFFFF
g.FillRect(0, 0, g.Width, g.Height)
// Black Border
g.PenWidth = 1
g.ForeColor = &c000000
g.DrawRect(0, 0, g.Width, g.Height)
// Draw the logo
Dim logoX As Integer = (g.Width-EELogo.Width)/2
Dim logoY As Integer = (g.Height-EELogo.Height)/2
g.DrawPicture(EElogo, logoX, logoY)
EElogo paints fine as EElogo is a PNG file included with the project.
However, if I do this:
Dim LLx As Integer = 50
Dim LLy As Integer = g.Height-50
Dim LRx As Integer = g.Width-50
// White Background
g.ForeColor = &cFFFFFF
g.FillRect(0, 0, g.Width, g.Height)
// Black Border
g.PenWidth = 1
g.ForeColor = &c000000
g.DrawRect(0, 0, g.Width, g.Height)
// Draw the logo
Dim logoX As Integer = (g.Width-EELogo.Width)/2
Dim logoY As Integer = (g.Height-EELogo.Height)/2
Dim p as Picture = EELogo
Dim Aspect as Double = p.Width/p.Height
Dim pleft as integer = ((me.Width/2)-(me.Height*Aspect/2))\\2
Dim p1 as New Picture((me.Width/2),(me.Height/2))
p1.graphics.DrawPicture(p,pleft,0,(me.height*aspect/2),(me.height/2),0,0,p.width,p.Height)
g.DrawPicture(p1, logoX, logoY)
The picture never paints because P1 is a picture in memory NOT on disk. Is this a bug? Expected behavior?
I’m simply trying to scale the picture. In many cases, this is needed as the picture may be too large to fit in the canvas. There is no scaling capabilities in the WebGraphics.DrawPicture method. So I want to scale to another image and then paint that image. But it doesn’t work.