Save screen
Publié : mer. 11/sept./2013 0:44

Enumeration
#Image
EndEnumeration
;
Im=CreateImage(#PB_Any,GetSystemMetrics_(#SM_CXSCREEN),GetSystemMetrics_(#SM_CYSCREEN))
hWnd=GetDesktopWindow_()
hDDC=GetDC_(hWnd)
hDC=StartDrawing(ImageOutput(Im))
BitBlt_(hDC,0,0,ImageWidth(Im),ImageHeight(Im),hDDC,0,0,#SRCCOPY)
StopDrawing()
;
;------------------------------------------------------------------------------* Programme principale *------------------------------------------------------------------------
Gosub print_screen
End
print_screen:
CreateImage(0,GetSystemMetrics_(#SM_CXSCREEN),GetSystemMetrics_(#SM_CYSCREEN))
DC = StartDrawing(ImageOutput(0))
BitBlt_(DC,0,0,ImageWidth(0),ImageHeight(0),GetDC_(GetDesktopWindow_()),0,0,#SRCCOPY )
StopDrawing()
hDC=StartDrawing(ImageOutput(Im))
BitBlt_(hDC,0,0,ImageWidth(Im),ImageHeight(Im),hDDC,0,0,#SRCCOPY)
StopDrawing()
ReleaseDC_(hWnd,hDDC)
ResizeImage(0,1366,768)
StopDrawing()
If OpenWindow(0, 10, 10, 1366, 768, "Screenshot", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
StartDrawing(WindowOutput(0))
DrawImage(ImageID(#Image),0,0 )
Im=DrawImage(ImageID(#Image),0,0 )
StopDrawing()
EndIf
;---------------------------------------------------------------------------* Enregistrement des images *----------------------------------------------------------------------
If OpenFile(0, "D:\img\image .bmp")
SaveImage(#Image,"D:\img\Image.bmp" )
CloseFile(0)
Else
Debug "ERREUR D'ECRITURE DU FICHIER D:\img\Image.bmp, #PB_ImagePlugin_BMP)"
EndIf
;
If OpenFile(Im, "d:\img\image.png",#PB_ImagePlugin_PNG)
SaveImage(Im, "d:\img\image.png",#PB_ImagePlugin_PNG)
CloseFile(1)
Else
Debug "ERREUR DE FICHIER d:\img\image.png"
EndIf
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
Return