There was a little mistake in my previously posted Sub:
Code: Select all
Put pimg, (x, y), @clr, PSet ' @clr was simply: clr (but, put wants a Ptr)
Since I've noted, that While/Wend loops are seemingly faster, than For/Next loops, at least
when using FBC 64 (GCC), I've recoded the CLR_IMG Sub and added some testing code:
Code: Select all
' ClearImage.bas -- 2017-05-26, by MrSwiss (compile: -s gui)
'
Sub CLR_IMG(ByVal img As Any Ptr, ByVal wth As ULong, ByVal hgt As ULong)
Dim As UInteger xc = 0, yc = 0 ' counter(s)
Dim As ULong clr = &h00FF00FF ' magic-pink (32bit)
While yc < hgt + 1 ' while/wend seems faster, than for/next in FBC 64bit
While xc < wth + 1
Put img, (xc, yc), @clr, PSet
xc += 1
Wend
yc += 1
Wend
End Sub
Const As ULong w_win = 1024, h_win = 768, iw = w_win-1, ih = h_win-1, _
red = &h3FFF0000, yellow = &hCFCFCF00, blue = &h3F007FCF
' proof of concept code ... only!
ScreenRes(w_win, h_win, 32, 2) ' 32bit, double buffer
ScreenSet(1, 0) ' working/visible page
'Width w_win\8, h_win\16 ' only needed for using: Locate & Print
Dim As Any Ptr bg_img = ImageCreate(3200, 1800, red, 32) ' all bg
Line bg_img, (50, 25)-Step(199, 149), yellow, BF ' proof of concept only
Circle bg_img, (600, 450), 120, blue,,,, F ' proof of concept only
Dim As Any Ptr buffer = ImageCreate(w_win, h_win,, 32) ' screen portion bg
Dim As Long x_offs = 100, y_offs = 50, cnt = 0 ' run time variable(s)
Do
CLR_IMG(buffer, iw, ih) ' isn't really needed (in this case!)
x_offs += 1 : y_offs += 1 ' move start pos(x,y), of portion 'to get'
Get bg_img, (x_offs, y_offs)-Step(iw, ih), buffer ' get portion of bg
Put (0, 0), buffer, Alpha : cnt += 1 ' blit it to working page
Flip ' copy to visible page
Sleep 10, 1 ' give CPU a break
If cnt = 180 Then cnt = 0 : x_offs = 100 : y_offs = 50 ' re-set
Loop Until Len(InKey) ' quit on user action (keyboard/mouse)
' clean up ...
ImageDestroy(bg_img) : bg_img = 0 ' release MEM | invalidate Ptr
ImageDestroy(buffer) : buffer = 0 ' as above
' ----- EOF -----