|
Post by wbtcpip on Jul 10, 2019 22:58:41 GMT 1
hi all, do you have any sample code that show how to horizontal scroll text in a label? like the latest news on the tv news channels.
thank you
|
|
|
Post by wbtcpip on Jul 11, 2019 1:14:44 GMT 1
exactly what i need! thank you!
|
|
|
Post by wbtcpip on Jul 14, 2019 1:21:02 GMT 1
Unfortunately i cannot use the code because the label flicker a lot making the text pretty unreadable. is there any another way to smooth scroll text horizontal? maybe with gdi+?
|
|
|
Post by wbtcpip on Jul 14, 2019 19:01:39 GMT 1
For now i solved the flicker problem using a textbox instead of a label
|
|
|
Post by dragonjim on Jul 14, 2019 22:05:14 GMT 1
Hi,
You should be able to get rid of the flicker by using the following function:
Procedure FlickerControl(frm As Form, state%) // v1 // state% : 0 - Suspend Rendering; 1 - Reinstate and Redraw ~SendMessage(frm.hWnd, WM_SETREDRAW, state%, 0) If state% = 1 Then ~RedrawWindow(frm.hWnd, Null, Null, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN) EndProcedure
In the Sub tmr1_Timer routine, insert FlickerControl(frm1, 0) as the first line of the routine and then FlickerControl(frm1, 1) at the end of the routine.
I'd be interested to know if this solves your problem.
|
|
|
Post by wbtcpip on Jul 15, 2019 14:48:20 GMT 1
ok i will try tonight
|
|
|
Post by wbtcpip on Jul 15, 2019 16:09:11 GMT 1
ok i just tried the timer routine is this: (tickervideo is the form containing the label lbtickervideo2) Sub scorritestovideo_Timer FlickerControl(tickervideo, 0) lbtickervideo2.Left = lbtickervideo2.Left - 1 If lbtickervideo2.Left < (-lbtickervideo2.Width) Then lbtickervideo2.Left = tickervideo.Width FlickerControl(tickervideo, 1) EndSub Procedure FlickerControl(frm As Form, state%) // v1 // state% : 0 - Suspend Rendering; 1 - Reinstate and Redraw ~SendMessage(frm.hWnd, WM_SETREDRAW, state%, 0) If state% = 1 Then ~RedrawWindow(frm.hWnd, Null, Null, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN) EndProcedure unfortunately the flicker is still there. take a look at this video: www.easybytez.com/2u46k8k1fxlwif i use a textbox the flicker is not there: www.easybytez.com/ycjjy7efe911
|
|
|
Post by scalion on Jul 15, 2019 21:16:04 GMT 1
Hi all, And using a simple hidden form, maybe that you enjoy  ?
Global String TXT = "- Je voudrais savoir une dernière chose, dit Harry. Est-ce que tout cela est réel ? Ou bien est-ce dans ma tête que ça se passe ?" OpenW 1 : AutoRedraw = 1 Form Hidden HF HF.AutoRedraw = True Set Me = Win_1
Ocx Label L L.FontSize = 20 L.Text = TXT L.Height = TwipsToPixelY(L.TextHeight("?")) + 10 L.Width = Min(TextWidth(L.Text) / 2, _X - 20) L.Top = 10 L.Left = _X / 2 - L.Width / 2 L.BackColor = RGB(255, 200, 100) L.BorderStyle = 1
Ocx Timer t t.Interval = 40 : t.Enabled = True
Do Sleep : Loop Until Me Is Nothing Sub Win_1_Destroy HF.Close EndSub
Sub t_Timer Static Long Offset Set Me = HF Set HF.Font = L.Font HF.BackColor = L.BackColor Offset = Mod(Succ(Offset + 2), TextWidth(L.Text) + L.Width) Cls RGBColor L.ForeColor, L.BackColor Text L.Width - Offset , 0, L.Text Set Me = Win_1 If L.BorderStyle = 0 BitBlt HF.hDC2, 0, 0, L.Width , L.Height , GetDC(L.hWnd), 1, 1, SRCCOPY Else BitBlt HF.hDC2, 1, 1, L.Width - 2, L.Height - 2, GetDC(L.hWnd), 1, 1, SRCCOPY EndIf EndSub
|
|
|
Post by dragonjim on Jul 17, 2019 22:32:36 GMT 1
Hi again, Thanks for testing FlickerControl - shame it didn't work. Just as an academic exercise, what is the interval of your Timer? I did a quick example and, with only a label on the form, any value over 35 worked with FlickerControl (example below). However, to get faster speeds than that, I just adjusted how far the label moved left (from 1 to 10 seems to give a smooth scroll, the latter at a comparative iteration of a leftward movement of just a single pixel every 0.0035 of a second; anything over 3 seems to blur - I tested it with speeds of 20 and it seemed flicker free, just too fast to read  ) OpenW 1 Ocx Label lbl = "", 100, 100, 400, 20 : .Transparent = True lbl.Text = "This is meant to be scrolling text................" Ocx Timer tmr : .Interval = 35 : .Enabled = True Do : Sleep : Until Win_1 Is Nothing Or Iif(Not IsNothing(tmr), tmr.Enabled = False, False) If Not IsNothing(tmr) Then tmr.Enabled = False
Sub tmr_Timer If lbl.Left > -200 FlickerControl(Win_1, 0) lbl.Left = lbl.Left - 1 // Change this to make faster DoEvents // Added to process any background messages which may produce a flicker effect - can be omitted. FlickerControl(Win_1, 1) Else tmr.Enabled = False EndIf EndSub
Procedure FlickerControl(frm As Form, state%) // v1 // state% : 0 - Suspend Rendering; 1 - Reinstate and Redraw ~SendMessage(frm.hWnd, WM_SETREDRAW, state%, 0) If state% = 1 Then ~RedrawWindow(frm.hWnd, Null, Null, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN) EndProcedure
|
|
|
Post by rogercabo on Feb 17, 2023 15:06:27 GMT 1
It's a bit late.. On the older Gfabasic I wrote a program that shifts a image on the screen by floating point values in grayscale. 30 years ago? I never had any idea what im doing in case of rendering an image with bi-linear filtering..
' Initialize screen and input SCREEN 12 CLS INPUT "Enter image width (in pixels): ", imgWidth INPUT "Enter image height (in pixels): ", imgHeight INPUT "Enter horizontal shift (in pixels): ", shiftX INPUT "Enter vertical shift (in pixels): ", shiftY
' Load image data into a 2D array DIM img(imgWidth, imgHeight) AS INTEGER LOAD "image.dat", img
' Create a copy of the image array DIM imgNew(imgWidth, imgHeight) AS INTEGER imgNew() = img()
' Loop through each pixel and shift it by the user-specified amount FOR y = 0 TO imgHeight - 1 FOR x = 0 TO imgWidth - 1 ' Determine the new x and y coordinates, accounting for floating-point shift values newX = x + shiftX newY = y + shiftY x1 = INT(newX) y1 = INT(newY) x2 = x1 + 1 y2 = y1 + 1 f1 = newX - x1 f2 = 1 - f1 g1 = newY - y1 g2 = 1 - g1 ' Calculate the blended color of the current pixel based on its surrounding pixels col1 = (img(x1, y1) * f2 + img(x2, y1) * f1) * g2 col2 = (img(x1, y2) * f2 + img(x2, y2) * f1) * g1 imgNew(x, y) = col1 + col2 NEXT x NEXT y
' Display the shifted image PUT (0, 0), imgNew, PSET
' Wait for user input before exiting WHILE INKEY$ = "" WEND
The same in RGB scale
REM Image shifting program with RGB color
REM Define the dimensions of the image DIM SHARED img(255, 255, 3)
REM Load the image LOADBMP "image.bmp", img()
REM Define the shift values DIM SHARED shiftX AS SINGLE DIM SHARED shiftY AS SINGLE
REM Set the shift values shiftX = 0.5 shiftY = 0.5
REM Main program loop WHILE INKEY$ = ""
REM Clear the screen SCREEN 0, 0, 0
REM Shift and redraw the image FOR y = 0 TO UBOUND(img, 2) FOR x = 0 TO UBOUND(img, 1)
REM Calculate the new position of the pixel newX = x + shiftX newY = y + shiftY
REM Calculate the color of the pixel by blending the surrounding colors r = 0 g = 0 b = 0 count = 0
FOR i = -1 TO 1 FOR j = -1 TO 1 pixelX = INT(newX + i) pixelY = INT(newY + j) IF pixelX >= 0 AND pixelX < UBOUND(img, 1) AND pixelY >= 0 AND pixelY < UBOUND(img, 2) THEN r = r + img(pixelX, pixelY, 0) g = g + img(pixelX, pixelY, 1) b = b + img(pixelX, pixelY, 2) count = count + 1 END IF NEXT j NEXT i
REM Calculate the average color of the surrounding pixels IF count > 0 THEN r = r / count g = g / count b = b / count END IF
REM Draw the pixel with the new color PSET (x, y), RGB(r, g, b)
NEXT x NEXT y
REM Update the screen SHOWPAGE
WEND
REM Save the modified image SAVEBMP "modified_image.bmp", img()
REM End of program END
|
|