@luis,
Hmmm, I don't see how putting GrabDrawingImage before you actually draw on the image demonstrates the GrabDrawingImage function.
It looks to me like your code only saves the image that you drew, not the image that you grabbed.
I tried but was unsuccessful in using GrabDrawingImage directly from a window.
I did discover that if you use drawingmode #PB_2DDrawing_XOr the lines are visible in the grabbed image using Michael Vogel's code.
GrabDrawingImage seems to work correctly when used with another image and presumably screen and canvas would work as well. It seems that it fails only when used directly from a window.
Code: Select all
;
Enumeration
#ImageGadget_01
#ImageGadget_02
#Image_01
#Image_02
#ButtonDraw
#ButtonGrab
EndEnumeration
If OpenWindow(0,0,0,434,240,"Win",#PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
SetWindowColor(0,RGB(0,96,96))
ButtonGadget(#ButtonDraw,010,5,80,20,"Draw")
ButtonGadget(#ButtonGrab,220,5,80,20,"Grab")
CreateImage(#Image_01,200,200)
CreateImage(#Image_02,200,200)
ImageGadget(#ImageGadget_01,010,30,200,200,ImageID(#Image_01),#PB_Image_Border)
ImageGadget(#ImageGadget_02,220,30,200,200,ImageID(#Image_02),#PB_Image_Border)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
quit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case #ButtonDraw
If StartDrawing(ImageOutput(#Image_01))
Box(040,75,50,50,Random($FFFFFF))
Box(110,75,50,50,Random($FFFFFF))
StopDrawing()
SetGadgetState(#ImageGadget_01,ImageID(#Image_01))
EndIf
Case #ButtonGrab
If StartDrawing(ImageOutput(#Image_01))
GrabDrawingImage(#Image_02,0,0,200,200)
StopDrawing()
SetGadgetState(#ImageGadget_02,ImageID(#Image_02))
EndIf
EndSelect
EndSelect
Until quit
EndIf