How to capture a window as .png from HTML viewer

Hello,

I have an HTML viewer which will display a web page.

I would like to save the current frame of that web page as a .png image by clicking on a pushbutton named CaptureWebPagePB, How can I do that?

Thanks.

Lennox

Declares and/or plugins will allow you to take a screenshot of the HTMLViewer or Window and then you can go from there.

Hi Sam,

I have this…

[code] Dim g As Graphics
DIM mP As Picture

mP = new Picture(Viewer.Width, Viewer.Height)
g = mP.Graphics

mp.Graphics.DrawPicture mP, 0, 0, Viewer.Width, Viewer.Height, Viewer.Left, Viewer.Top, Viewer.Width, Viewer.Height

Dim TheFolderitem as FolderItem
TheFolderitem = SpecialFolder.Desktop.Child(“My Picture.JPEG”)

mP.Save(TheFolderitem, Picture.SaveAsJPEG)

[/code]

but I get a blank picture.

Lennox

https://forum.xojo.com/8025-htmlviewer-image-to-canvas-question?search=ControlSnapShot

[quote=351574:@Lennox Jacob]Hi Sam,

I have this…

[code] Dim g As Graphics
DIM mP As Picture

mP = new Picture(Viewer.Width, Viewer.Height)
g = mP.Graphics

mp.Graphics.DrawPicture mP, 0, 0, Viewer.Width, Viewer.Height, Viewer.Left, Viewer.Top, Viewer.Width, Viewer.Height

Dim TheFolderitem as FolderItem
TheFolderitem = SpecialFolder.Desktop.Child(“My Picture.JPEG”)

mP.Save(TheFolderitem, Picture.SaveAsJPEG)

[/code]

but I get a blank picture.

Lennox[/quote]
Right, because you’re drawing mP into mP.

Absolutely fantastic…

Thanks Matthew and Michel.

Lennox

I want to add that in MBS Plugins, we do have functions to extend HTMLViewer and get pictures:

see
http://monkeybreadsoftware.net/class-htmlviewer.shtml

e.g. RenderWebsiteImageMBS for Mac which renders the image of a web viewer quite nice, not just what you see, but also what you can see when scrolling.