GDI+ Drawing without utilization much CPU?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi everyone!
Im working on GDI+ (System.Drawing) on a Winform platform. My job is draw visualization for an audio player. Its simple a 16-bars visualizations. When everything is ok (it runs fine) then the cpu usage is 50% constant when it runs.
This is the code:Private sub Ref (a as object, e as eventargs) handles T.tick
UpdateRectangles()
W.Invalidate()
End Sub

Private sub Paint (a as object, e as painteventargs) handles W.Paint

for each r as rectangle in bars
e.graphics.fillrectangle(bx,r)
next

End Sub

Where r is a collection of rectangle, and it will be refreshed to get new values corresponding to audio wave frequencies (UpdateRectangles). The timer have an interval of 10ms.
Compare with Wmplayer, it draws a lot more than 16 rectangles with cpu utilization above 10%, and in media player SDK says taht we can use GDI to draw.
So is there a way to draw, without utilization much cpu like the way Wmplayer do it?
Call me Zenocoding

View the full article
 
Back
Top