09-17-2023, 08:11 PM
Hi Terry,
Hi Steve
I have found this wiki example in which _PUTIMAGE works with hardware images ... AND in this code there is no _DestHandle&.
Before reading Steve's answer I have thought that it was because _DEST 0 is screen in use and displayed as output.
Now I am asking to myself if the absence of _destHandle& is a tip or a coincidence.
taken from this wiki page Hardware images.
well Step 1:
we create an image surface on which we put the hardware images
and from this last image we _Putimage on the screen (_Dest 0)
and there is no issue
moreover we attempt to _putimage the hardware images directly on a software image and then we copy this last on the screen surface...
(we delete _Dest 0 and _Dysplayorder instructions!) and all seem working well!
we need more informations !
Why does Terry get invalid handle error and this code no?
Hi Steve
I have found this wiki example in which _PUTIMAGE works with hardware images ... AND in this code there is no _DestHandle&.
Before reading Steve's answer I have thought that it was because _DEST 0 is screen in use and displayed as output.
Now I am asking to myself if the absence of _destHandle& is a tip or a coincidence.
Code: (Select All)
SCREEN _NEWIMAGE(640, 480, 32)
'create some software screens
scr_bg = _NEWIMAGE(640, 480, 32)
scr_fg = _NEWIMAGE(50, 50, 32)
'draw to the background one, and make a nice pattern
_DEST scr_bg
FOR i = 1 TO 100
LINE (RND * 640, RND * 480)-(RND * 640, RND * 480), _RGBA32(RND * 255, RND * 255, RND * 255, RND * 255), BF
NEXT i
'create a hardware screen version of the background
scrh_bg = _COPYIMAGE(scr_bg, 33)
_FREEIMAGE scr_bg 'we no longer need the software version in memory
'then do the same thing for the foreground
_DEST scr_fg
LINE (0, 0)-(50, 50), _RGBA32(255, 255, 255, 200), BF
'copy to hardware screen
scrh_fg = _COPYIMAGE(scr_fg, 33)
_FREEIMAGE scr_fg 'and free software screen from memory
'set image destination to main screen
_DEST 0
_DISPLAYORDER _HARDWARE 'do not even render the software layer, just the hardware one.
DO 'main program loop
'_putimage knows these are hardware screens, so destination of 0 is taken as hardware layer
_PUTIMAGE , scrh_bg
_PUTIMAGE (x, y), scrh_fg
'just some input processing
k = _KEYHIT
SELECT CASE k
CASE ASC("w"): y = y - 1
CASE ASC("a"): x = x - 1
CASE ASC("s"): y = y + 1
CASE ASC("d"): x = x + 1
END SELECT
_DISPLAY 'render image after changes
_LIMIT 30 'we're doing all this at 30 cycles/second
LOOP
well Step 1:
we create an image surface on which we put the hardware images
and from this last image we _Putimage on the screen (_Dest 0)
and there is no issue
Code: (Select All)
Screen _NewImage(640, 480, 32)
'create some software screens
scr_bg = _NewImage(640, 480, 32)
scr_fg = _NewImage(50, 50, 32)
'draw to the background one, and make a nice pattern
_Dest scr_bg
For i = 1 To 100
Line (Rnd * 640, Rnd * 480)-(Rnd * 640, Rnd * 480), _RGBA32(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255), BF
Next i
'create a hardware screen version of the background
scrh_bg = _CopyImage(scr_bg, 33)
_FreeImage scr_bg 'we no longer need the software version in memory
'then do the same thing for the foreground
_Dest scr_fg
Line (0, 0)-(50, 50), _RGBA32(255, 255, 255, 200), BF
'copy to hardware screen
scrh_fg = _CopyImage(scr_fg, 33)
_FreeImage scr_fg 'and free software screen from memory
'set image destination to main screen
Dim ScreenC As Long
_Dest ScreenC
'_Dest 0
_DisplayOrder _Hardware 'do not even render the software layer, just the hardware one.
Do 'main program loop
'_putimage knows these are hardware screens, so destination of 0 is taken as hardware layer
_PutImage , scrh_bg
_PutImage (x, y), scrh_fg
_PutImage (0, 0), ScreenC, 0
'just some input processing
k = _KeyHit
Select Case k
Case Asc("w"): y = y - 1
Case Asc("a"): x = x - 1
Case Asc("s"): y = y + 1
Case Asc("d"): x = x + 1
End Select
_Display 'render image after changes
_Limit 30 'we're doing all this at 30 cycles/second
Loop
moreover we attempt to _putimage the hardware images directly on a software image and then we copy this last on the screen surface...
(we delete _Dest 0 and _Dysplayorder instructions!) and all seem working well!
Code: (Select All)
Screen _NewImage(640, 480, 32)
'create some software screens
scr_bg = _NewImage(640, 480, 32)
scr_fg = _NewImage(50, 50, 32)
'draw to the background one, and make a nice pattern
_Dest scr_bg
For i = 1 To 100
Line (Rnd * 640, Rnd * 480)-(Rnd * 640, Rnd * 480), _RGBA32(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255), BF
Next i
'create a hardware screen version of the background
scrh_bg = _CopyImage(scr_bg, 33)
_FreeImage scr_bg 'we no longer need the software version in memory
'then do the same thing for the foreground
_Dest scr_fg
Line (0, 0)-(50, 50), _RGBA32(255, 255, 255, 200), BF
'copy to hardware screen
scrh_fg = _CopyImage(scr_fg, 33)
_FreeImage scr_fg 'and free software screen from memory
'set image destination to software image that has been copied on the main screen
Dim ScreenC As Long
Do 'main program loop
'_putimage knows these are hardware screens, so destination of 0 is taken as hardware layer
_PutImage , scrh_bg, ScreenC
_PutImage (x, y), scrh_fg, ScreenC
_PutImage (0, 0), ScreenC, 0
'just some input processing
k = _KeyHit
Select Case k
Case Asc("w"): y = y - 1
Case Asc("a"): x = x - 1
Case Asc("s"): y = y + 1
Case Asc("d"): x = x + 1
End Select
_Display 'render image after changes
_Limit 30 'we're doing all this at 30 cycles/second
Loop
Why does Terry get invalid handle error and this code no?