Page 1 of 1

How to make GrabSprite() work properly?

Posted: Thu Feb 26, 2004 8:14 pm
by merendo
Hi @ll

i am just hunting a very strange bug but I really dunno if it's really a bug or i am just too stupid which is more propable :)

However, i have a 800*600*16bit Fullscreen and want to make a screenshot when the key F12 is pressed. But in my code, the programme just exits without any error message, even the debugger quits without complaining about any errors when i press F12... Could you please give me a simple example how to properly make a screenshot using GrabSprite and tell me what i have to pay attention to if i do not want to cause a bug....

Please help me, my brain is offline...

-- edit:

Please delete this topic.

Posted: Thu Feb 26, 2004 8:35 pm
by filperj
I don't see any problem with grabsprite :roll:
Does this run right for you ?

Code: Select all


#bmpfile= ;name a bmp

LoadImage(0,#bmpfile)

InitSprite()

OpenScreen(800,600,16,"")

StartDrawing(ScreenOutput())
  DrawImage(UseImage(0),0,0,800,600)
StopDrawing()
FreeImage(0)

GrabSprite(0,0,0,800,600)

InitMouse()
While MouseButton(1)=0
  ClearScreen(0,0,0)
  ExamineMouse()
  DisplaySprite(0,MouseX(),MouseY())
  FlipBuffers()
Wend


Posted: Thu Feb 26, 2004 9:03 pm
by merendo
Yes it does... Well, but i think this one should also run properly...

Code: Select all

Procedure Loopbottom()
  DisplaySprite(#mousea,mx,my)
  DisplayTransparentSprite(#mouseb,mx,my)
  mousehitl=MouseHitL()
  mousehitr=MouseHitR()
  If KeyboardReleased(#PB_Key_F12)
    GrabSprite(#screenshot,0,0,800,600)
  EndIf
  FlipBuffers()
EndProcedure
Loopbottom is called at the end of each game loop just before the 'until' operator. #mousea and #mouseb are the pointer images and mx and my the coordinates of the mouse. MouseHitL() checks if the left mousebutton has been pushed (returns 1 only once, not like Mousebutton() as long as the mousebutton is pushed), the same for MouseHitR() with the right button. I think this should work, #screenshot is declared in a Declaration as the first element.

Posted: Thu Feb 26, 2004 9:17 pm
by filperj
I don't see what can be wrong :roll:
Is there a "usebuffer" in your prog?

Posted: Thu Feb 26, 2004 10:37 pm
by merendo
No way. But the programme keeps crashing...

Posted: Thu Feb 26, 2004 10:41 pm
by Dreglor
it may be becasue what ever code that looks for the f12 key, i not sure how, but it cause the program to jump to the end and shut down

Posted: Thu Feb 26, 2004 10:54 pm
by merendo
Well, if i got what you said, i'll try it with F11...

There is something curious: When i change the If F12-pushed Endif Condition into this:

Code: Select all

  If KeyboardReleased(#PB_Key_F12)
    Delay(5000)
    GrabSprite(#screenshot,0,0,800,600)
  EndIf
The code crashes immediately after i pushed F12... It doesn't wait for 5 secs and then crash... What could this be?

-- edit:
ARGH! EACH key crashes my programme... But why? I DO call Examinekeyboard at the beginning of each loop...

-- edit:

Okay. I got it. I really was too stupid, feel free to hit me! Sorry many times for disturbing you with this topic. I had a network party last night so i miss about 8 hours of sleep... Sorry again, it was my stupid fault!