07-27-2025, 02:02 AM
Since it's so quiet around here, I'll ask a question I've been wondering about...
After getting shot down by Steve on my image handling and creating memory leaks a couple weeks ago [Image Issues, Post #5], I wanted to run this by the Council of Wise Men. In this little prog PCopy and _CopyImage seem to be inter-changeable. I'm not using PCopy for page flipping, just simply for copying the _Display to a virtual screen or copying one image to another screen. It seems like using PCopy is less likely to get me in trouble with over-writing image handles and creating leaks.
So is there anything I should know about the difference between these two commands in this situation?
If you remark out line 26 (_CopyImage) and activate line 27 (PCopy), both versions work fine as written... Thanks.
After getting shot down by Steve on my image handling and creating memory leaks a couple weeks ago [Image Issues, Post #5], I wanted to run this by the Council of Wise Men. In this little prog PCopy and _CopyImage seem to be inter-changeable. I'm not using PCopy for page flipping, just simply for copying the _Display to a virtual screen or copying one image to another screen. It seems like using PCopy is less likely to get me in trouble with over-writing image handles and creating leaks.
So is there anything I should know about the difference between these two commands in this situation?
If you remark out line 26 (_CopyImage) and activate line 27 (PCopy), both versions work fine as written... Thanks.
Code: (Select All)
Screen _NewImage(500, 500, 32)
Dim Image&, image2&
$Color:32
_PrintMode _KeepBackground: _ScreenMove _Middle: Randomize Timer
start:
Image& = _NewImage(500, 500, 32) ' create 2 virtual screens
image2& = _NewImage(500, 500, 32)
Cls: Color Gray
Locate 12, 11: Print "Press a Key to Record Screen. <ESC> to End."
_Delay .65: _KeyClear
Do: Color _RGB32(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 215 + 40)
_PrintString (Rnd * _Width, Rnd * _Height), Chr$(Int(Rnd * 255 + 1))
PCopy _Display, Image& ' save current screen to image& IN A LOOP USING PCOPY <<<<
_Limit 240
Loop Until _KeyHit
If _KeyDown(27) Then
_FreeImage Image&
_FreeImage image2& '
System ' off ramp
End If
Cls: Color ChartReuse
Locate 10, 26: Print "Press a key.": Sleep
' copy image to 2nd screen for testing
image2& = _CopyImage(Image&, 32)
'PCopy Image&, image2& ' these both work <<<<
_PutImage , image2&
Color White: Locate 17, 17: Print "COPIED SCREEN... PRESS A KEY!"
Sleep
_FreeImage Image& ' free images
_FreeImage image2& '
GoTo start


But you can use `_PutImage` to use the 'new' image commands and still stay out of trouble.