Webcanvas to shows a picture of a other web sites, How to implement?
???
Webcanvas to shows a picture of a other web sites, How to implement?
???
Better use a WebImageView (Image Well) with the URL of that picture on the other site.
when I use a WebImageView,I can not see the picture in iphone browser
You may try to display the picture in a WebHTMLViewer.
Or use an HTTPSocket to grab the picture, then you will be able to use it to draw in the canvas. But it is more overhead.
Thank you for your reply. Now I can use HTTPSocket to grap the Picture, but I don not konw How to draw it int the Canvas? Can you give me an example?
Use the DrawPicture method of WebGraphics in the Paint event. Described here http://documentation.xojo.com/index.php/WebGraphics
Thank you for your reply!
[code]Sub Paint(g as WebGraphics)
dim picdata as string
dim MyHttpSocket as new HTTPSocket
picdata = MyHttpSocket.get(“https://www.baidu.com/img/bd_logo1.png”,2)
dim pic as new WebPicture(picdata,“Mypicture.png”)
g.DrawPicture(pic,0,0,me.Width,me.Height)
End Sub[/code]
Error occurred NilObjectException at " g.DrawPicture(pic,0,0,me.Width,me.Height)" ,I don’t know how to fix it.
It is possible that you don’t leave enough time for the picture to download.
I would make pic a property of the webPage, and place the first part of your code in a method, for instance getPic
sub getPic(url as string)
dim picdata as string
dim MyHttpSocket as new HTTPSocket
picdata = MyHttpSocket.get(url,2)
pic = new WebPicture(picdata,"Mypicture.png")
myWebCanvas.invalidate
end sub
It could also be that you’re grabbing the image in the paint event. I suggest doing this on the outside and create the webpicture once.
But still the same mistakes.