I need advice, according display scrolling text on TV.
What is the best solution?
We try move label, with timer - to slow...
We try BitBlt - we have a flicking...
With DirectX, similar situation...
What is the right solution?
Thanks,
Jovo
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Smooth realtime scrolling (attention: quick&dirty solution):
Private Sub Form1_Activated( _
ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Activated
Static done As Boolean
If Not done Then
Const Text As String = "Scrolling"
Dim Backbuffer As Bitmap
Dim gBack, gFront As Graphics
Dim StartTick As Integer
Dim size As SizeF
done = True
Me.Font = New Font("Arial", 30, FontStyle.Bold)
Backbuffer = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
gBack = Graphics.FromImage(Backbuffer)
gFront = Me.CreateGraphics
size = gBack.MeasureString(Text, Me.Font)
StartTick = Environment.TickCount
Do
'Render
Dim pos As PointF
Dim x, y As Single
Dim Duration As Integer
Duration = Environment.TickCount - StartTick
x = (Me.ClientSize.Width - size.Width) / 2.0F
y = Me.ClientSize.Height - Duration / 20.0F
If y < -size.Height Then StartTick = Environment.TickCount
pos = New PointF(x, y)
gBack.Clear(Color.Black)
gBack.DrawString(Text, Me.Font, Brushes.White, pos)
'Flip
gFront.DrawImageUnscaled(Backbuffer, 0, 0)
Application.DoEvents()
Loop While Me.Visible
gBack.Dispose()
gFront.Dispose()
End If
End Sub
--
Armin
I've done some small (flickerfree) animations using this technique and GDI
in VB6 but always got much higher rates (700MHz+Geforce 1). Maybe rendering
was not very fast, but Bitblt ("flipping") was not noticable slow.
I'm getting 44 FPS here. Clientsize: 920x672 (XP1600+, GF4Ti4200). Below the
changed code, now displaying FPS.
I don't know why/if it's flickering on TV. Wouldn't be a programming issue,
I guess... So, not my problem. :)
Armin
Private Sub Form1_Activated( _
ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Activated
Static done As Boolean
If Not done Then
Const Text As String = "Scrolling"
Dim Backbuffer As Bitmap
Dim gBack, gFront As Graphics
Dim StartTick, FPSTick As Integer
Dim size As SizeF
Dim FPSFont As New Font("Courier New", 10)
Dim FPSText As String
Dim FPSCounter As Integer
done = True
Me.Font = New Font("Arial", 30, FontStyle.Bold)
Backbuffer = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
gBack = Graphics.FromImage(Backbuffer)
gFront = Me.CreateGraphics
size = gBack.MeasureString(Text, Me.Font)
StartTick = Environment.TickCount
Do
Dim f2 As Form1
'Render
Dim pos As PointF
Dim x, y As Single
Dim Duration, FPSDuration As Integer
Dim Ticks As Integer
Ticks = Environment.TickCount
Duration = Ticks - StartTick
x = (Me.ClientSize.Width - size.Width) / 2.0F
y = Me.ClientSize.Height - Duration / 20.0F
If y < -size.Height Then StartTick = Environment.TickCount
pos = New PointF(x, y)
gBack.Clear(Color.Black)
gBack.DrawString(Text, Me.Font, Brushes.White, pos)
gBack.DrawString(FPSText, FPSFont, Brushes.White, 0, 0)
'Flip
gFront.DrawImageUnscaled(Backbuffer, 0, 0)
'FPS
FPSCounter += 1
FPSDuration = Ticks - FPSTick
If FPSDuration >= 1000 Then
FPSText = (FPSTick / FPSDuration / 1000).ToString("0.0")
FPSTick = Ticks
FPSCounter = 0
End If
1. Today I started it again: 13.5 FPS. 8-/ I didn't change anything.
Neither the code nor screen resolution or anything else.... It's 13.5 FPS,
no matter what form size I choose in design mode. Strange...
2. I set windowstate = maximized at design time and tested it (1280x1024
fullscreen). Nothing happened. Why? The Activated-Event did not occur!
Another bug?
Armin
"Jeremy" <thevis...@hotmail.com> schrieb
> I couldn't understand why your code was running so much faster
> than mine until I realized that in my code I using the Alpha
> channel. Blending my entire buffer @ 1024x768 is prolly not the
> best way to do it hehe.
>
> :)
>
>
>
> "Armin Zingler" <az.n...@freenet.de> wrote in message
> news:eqM2edfF...@tk2msftngp13.phx.gbl...
Thanks Armin,
but I still have a problem... I try this code, it is OK on the Monitor,
but is is not OK on the TV OUT... (I have a flicking...)
Why do you think you have a VB problem?
--
Armin
I'm not looking for the fastest way. :) Just been playing around (fun).
Downloaded only the DXVB SDK (huge enough): Billboard sample @ 400x300:
300FPS in FG, 10FPS in BG. Getting a little OT now... ;-)
--
Armin
"Tiny" correction:
replace
FPSText = (FPSTick / FPSDuration / 1000).ToString("0.0")
by
FPSText = (FPSCounter / FPSDuration * 1000).ToString("0.0")
8-/ he he he
Ok, now I'm getting realistic 270 FPS@256x256 and 18 FPS@1280x1024
(BTW, I'll never understand why it's smooth but sometimes jumping although
there's nothing relevant running in the background)
--
Armin
No, I measured the time per frame (the whole part between Do and Loop) for
some hundreds or thousands of frames, and all values are within a small
range. But when I look at it, it's not animated 100% fluently, not even at
300FPS. I've always wondered why - it also happened in VB6 and/or even when
using the high performance counter instead of TickCount.
Well, wrong group for a deeper discussion.
Armin
Armin
"Jeremy" <thevis...@hotmail.com> schrieb im Newsbeitrag
news:UBSua.24087$ut.3...@twister.tampabay.rr.com...
And when you test on a monitor, you say, it works well => no VB problem, IMHO.
--
Armin