2013年6月18日 星期二

Procedure.s CaptureScreen()


Procedure.s CaptureScreen()
  dm.DEVMODE
  BMPHandle.l
  Width=GetSystemMetrics_(#SM_CXSCREEN)
  Height=GetSystemMetrics_(#SM_CYSCREEN)
  srcDC = CreateDC_("DISPLAY", "", "", dm)
  trgDC = CreateCompatibleDC_(srcDC)
  BMPHandle = CreateCompatibleBitmap_(srcDC, Width, Height)
  SelectObject_( trgDC, BMPHandle)
  BitBlt_( trgDC, 0, 0, Width, Height, srcDC, 0, 0, #SRCCOPY)
  DeleteDC_( trgDC)
  ReleaseDC_( BMPHandle, srcDC)
 
  If BMPHandle
    Id=CreateImage(#PB_Any, Width, Height)
    StartDrawing(ImageOutput(Id))
    DrawImage(BMPHandle,0,0)
    StopDrawing()    
    ;UsePNGImageEncoder()
    UseJPEGImageEncoder()
    file.s=GetTemporaryDirectory()+"~"+FormatDate("%hh%ii%ss", Date())+".tmp"
    ;SaveImage(Id,file,#PB_ImagePlugin_PNG) 
    SaveImage(Id,file,#PB_ImagePlugin_JPEG,2,24)   
    FreeImage(Id)    
  EndIf
  ProcedureReturn file
EndProcedure
Debug CaptureScreen()

沒有留言:

張貼留言