Page 1 of 1

Screenshotting!

Posted: Fri Jul 29, 2005 7:24 pm
by DBAlex
Hi, I have this code in my main loop...

Code: Select all

    
If KeyboardPushed(#PB_Key_p)
SaveSprite(6, "c:/screenshot.bmp")
GrabSprite(6,0,0,640,480)
EndIf
For taking a screenshot, But the image saves wierdly... Heres the bmp converted to JPG of what It looks like...

Image

So how can I correct this?

Im using the OpenScreen for graphics...

Thanks if you can help :? !

Posted: Fri Jul 29, 2005 7:44 pm
by coma
hi.
try to grab before saving.

Posted: Fri Jul 29, 2005 7:53 pm
by DBAlex
Ive tried that too...

Still mumbled...

Forgot to change the lines round after that :oops:

Posted: Fri Jul 29, 2005 8:26 pm
by Droopy
Try this ( code from ?? )


Code: Select all

;capture a piece of screen 
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 

ScreenCaptureAddress = CaptureScreen(0, 0, 1024, 768) 

UseJPEGImageEncoder() 


CreateImage(0, 1024, 768) 
StartDrawing(ImageOutput()) 
DrawImage(ScreenCaptureAddress, 0, 0) 
StopDrawing() 
SaveImage(0, "d:\Screenshot.jpg",#PB_ImagePlugin_JPEG)

Posted: Fri Jul 29, 2005 8:50 pm
by DBAlex
Thankyou for all the help!

I found a good screenshot program now though!

:)

Posted: Fri Jul 29, 2005 9:30 pm
by Joakim Christiansen
My screenshot code :wink: :

Code: Select all

Enumeration ;Sprites
  #spr_ScreenShot
EndEnumeration
Global ScreenShots.w

Procedure SaveScreen()
  ScreenShots + 1
  GrabSprite(#spr_ScreenShot,0,0,640,480)
  SaveSprite(#spr_ScreenShot,"screenshot"+Str(ScreenShots)+".bmp")
  FreeSprite(#spr_ScreenShot)
EndProcedure

Posted: Fri Jul 29, 2005 9:31 pm
by Nik
Please set Screenshots.w as Static thats better style and its safer^^
bye Nik

Posted: Sat Jul 30, 2005 2:16 am
by PB
> GrabSprite(#spr_ScreenShot,0,0,640,480)

FYI: while this works, it requires that DirectX be installed, which not all PCs may have.