Save WebGadget contents as image?
Save WebGadget contents as image?
Is there a way to save whatever is displayed in the WebGadget as an image?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Not much I can say about it, but in case it might help;
I used such a program some time ago and it apparantly made a screenshot of the window, then automatically scrolled to a new position, made screenshot again and so on until it had the entire content and finally puzzled the pieces together.
Maybe now it's possible to get a complete screenshot using the render engine, but the above way seems to be relatively easy to implement. Relatively.
Edit:
Is it possible to use the print mechanism, using a printer driver that creates an image?
I used such a program some time ago and it apparantly made a screenshot of the window, then automatically scrolled to a new position, made screenshot again and so on until it had the entire content and finally puzzled the pieces together.
Maybe now it's possible to get a complete screenshot using the render engine, but the above way seems to be relatively easy to implement. Relatively.
Edit:
Is it possible to use the print mechanism, using a printer driver that creates an image?
Athlon64 3800+ · 1 GB RAM · Radeon X800 XL · Win XP Prof/SP1+IE6.0/Firefox · PB 3.94/4.0
Intel Centrino 1.4 MHz · 1.5 GB RAM · Radeon 9000 Mobility · Win XP Prof/SP2+IE6.0/Firefox · PB 3.94/4.0
Intel Centrino 1.4 MHz · 1.5 GB RAM · Radeon 9000 Mobility · Win XP Prof/SP2+IE6.0/Firefox · PB 3.94/4.0
Re: Save WebGadget contents as image?
Only a screenshot of the webgadget.PB wrote:Is there a way to save whatever is displayed in the WebGadget as an image?
ARGENTINA WORLD CHAMPION
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
Fast code, not the best, but give you an idea and get the picture of the webgadget
Code: Select all
UseJPEGImageEncoder()
Global xX, yY
xX = GetSystemMetrics_(#SM_CXSCREEN) : yY = GetSystemMetrics_(#SM_CYSCREEN)
Procedure.l CaptureScreen(Left.l, Top.l, Width.l, Height.l)
dm.DEVMODE
BMPHandle.l
srcDC = CreateDC_("DISPLAY", "", "", dm)
trgDC = CreateCompatibleDC_(srcDC)
BMPHandle = CreateCompatibleBitmap_(srcDC, Width, Height)
SelectObject_( trgDC, BMPHandle)
BitBlt_( trgDC, 0, 0, Width, Height, srcDC, Left, Top, #SRCCOPY)
DeleteDC_( trgDC)
ReleaseDC_( BMPHandle, srcDC)
ProcedureReturn BMPHandle
EndProcedure
Procedure CreaImagen()
DeleteFile("Screenshot.jpeg")
ScreenCaptureAddress = CaptureScreen(20,40,xX-50,yY-150)
CreateImage(0, xX, yY)
StartDrawing(ImageOutput())
DrawImage(ScreenCaptureAddress, 0, 0)
StopDrawing()
SaveImage(0, "Screenshot.jpeg",#PB_ImagePlugin_JPEG,10)
Beep_(1999,100)
ProcedureReturn 1
EndProcedure
If OpenWindow(0,0,0,xX,yY,#PB_Window_SystemMenu,"Test")
CreateGadgetList(WindowID())
ButtonGadget(2,(xX/2),yY-90,150,25,"Take Picture")
WebGadget(3,10,10,xX-50,yY-150,"http://www.google.com")
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case 2
CreaImagen()
EndSelect
EndSelect
Until EventID=#PB_EventCloseWindow
EndIf
ARGENTINA WORLD CHAMPION
I'm working on a app that converts a web page into a JPG/PNG/BMP image. You can choose to take a snapshot of the viewable area of the web page, or take a snapshot of the entire page, even though it's not in view.
Converts this to this.
This is a stage 1 prototype for a possible commercial app I'm woking on. I can't release the source, but if it's for your personal use, and you're interested, I'll see if I can make a lib for you to use.

Converts this to this.
This is a stage 1 prototype for a possible commercial app I'm woking on. I can't release the source, but if it's for your personal use, and you're interested, I'll see if I can make a lib for you to use.

What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
- Michael Vogel
- Addict
- Posts: 2806
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Hi,
found this good ol' thread when searching for a possibility to get a google map into an image...
I have two problems now:
- I am able to get a picture which conatins only the upper 100 of the web content, the rest stays white
- if I try to do the whole process hidden (adding the #PB_Window_Invisible flag) , the image stays completely black (okay that's for phase 2
)
I have already inserted even a longer delay before saving the picture, but the result have been exactly the same...
Can anyone give me a hint, what I'm doing wrong here?
Thanks,
Michael
found this good ol' thread when searching for a possibility to get a google map into an image...
I have two problems now:
- I am able to get a picture which conatins only the upper 100 of the web content, the rest stays white
- if I try to do the whole process hidden (adding the #PB_Window_Invisible flag) , the image stays completely black (okay that's for phase 2

I have already inserted even a longer delay before saving the picture, but the result have been exactly the same...
Can anyone give me a hint, what I'm doing wrong here?
Thanks,
Michael
Code: Select all
Procedure SavePicture()
UsePNGImageEncoder()
DeleteFile("c:\Screenshot.png")
windowhandle=WindowID(0)
GetClientRect_(windowhandle, @cr.RECT)
CreateImage(0, cr\right-cr\left, cr\bottom-cr\top, 24)
hdc=StartDrawing(ImageOutput(0))
SendMessage_(windowhandle, #WM_PRINT, hdc, #PRF_CLIENT|#PRF_CHILDREN|#PRF_ERASEBKGND|#PRF_CHECKVISIBLE )
StopDrawing()
Debug SaveImage(0, "c:\Screenshot.png",#PB_ImagePlugin_PNG)
EndProcedure
If OpenWindow(0,0,0,800,500,"X",#PB_Window_SizeGadget | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget |#PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
WebGadget(1, 0, 0, 800, 500, "http://www.purebasic.com",#PB_Web_Mozilla )
saveflag=0
Repeat
Event = WaitWindowEvent(100)
If saveflag=1
Debug "wait..."
If GetGadgetAttribute(1,#PB_Web_Busy)=0
Delay(10)
Debug "Save now!"
saveflag=2
Repeat
WindowEvent()
Until WaitWindowEvent(0)=0
SavePicture()
EndIf
EndIf
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Select EventType()
Case #PB_Event_DataReceived
;Debug "Data"
Case #PB_EventType_DownloadEnd
If saveflag=0
saveflag=1
EndIf
;Debug "Download"
Case #PB_EventType_StatusChange
;Debug "Changes"
EndSelect
EndSelect
EndSelect
Until Event=#PB_Event_CloseWindow
EndIf
-
- New User
- Posts: 8
- Joined: Fri Nov 03, 2006 8:58 am
The following works for me:
Code: Select all
Procedure SavePicture()
UsePNGImageEncoder()
DeleteFile("c:\Screenshot.png")
windowhandle=GadgetID(1)
GetClientRect_(windowhandle, @cr.RECT)
CreateImage(0, cr\right-cr\left, cr\bottom-cr\top, 24)
hdc=StartDrawing(ImageOutput(0))
SendMessage_(windowhandle, #WM_PRINT, hdc, #PRF_CLIENT|#PRF_CHILDREN|#PRF_ERASEBKGND)
StopDrawing()
Debug SaveImage(0, "c:\Screenshot.png",#PB_ImagePlugin_PNG)
EndProcedure
perhaps this could be useful too:
http://www.purebasic.fr/english/viewtop ... 652#268652
Greetings ... Kiffi
http://www.purebasic.fr/english/viewtop ... 652#268652
Greetings ... Kiffi
Hygge
- Michael Vogel
- Addict
- Posts: 2806
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact: