Buffered images

BlitzMax Modules Forums/Brucey's Modules/Buffered images

Hi!
I want to draw an oscilloscope dynamically. I think it is better to use double buffered images to avoid flickering.

My idea:
A timer check all x milliseconds if a new audio signal is avariable. If it avraible then the oscilloscope is draw in a "Backbuffer Memory DC" and a OnPaint event is proceed manually.

On the OnPaint event the "Backbuffer Memory DC" is drawn in a Picturebox(wxStaticBitmap or wxImage?)

So how can I do that? Do I need a wxStaticBitmap or wxImage to draw a dynamic image? How can I create a memory DC and than show in the Picturebox?

That you can imagine what I want to do:


cu olli

Edit:
SuperStrict

Framework wx.wx
Import wx.wxApp
Import wx.wxFrame
Import wx.wxPanel
Import wx.wxTimer

Import BRL.Random

Global Application : TApplication, ..
       Frame       : TFrame

Application = New TApplication
Application.Run()

Type TApplication Extends wxApp
	Method OnInit:Int()
		Frame = New TFrame
		Frame.Create(,,"Drawing test")
		SetTopWindow(Frame)
		Frame.Show()
		
		Return True
	End Method
End Type

Type TFrame Extends wxFrame
	Field Panel : TDrawPanel, ..
	      Timer : TTimer
	
	Method OnInit()
		Local Sizer : wxBoxSizer
		Sizer = New wxBoxSizer.Create(wxVERTICAL)
		
		Panel = New TDrawPanel
		Panel.Create(Self, wxID_ANY)
		Sizer.Add(Panel, 1, wxALL|wxEXPAND, 0)
		
		Timer = New TTimer
		Timer.Create()
		Timer.Start(100)
		
		Self.SetSizer(Sizer)
		Self.Layout()
	End Method
End Type

Type TDrawPanel Extends wxPanel
	Field Color : Byte[3]

	Method OnInit()
		ConnectNoId(wxEVT_PAINT, OnPaint)
	End Method
	
	Method SetColor(Red:Byte, Green:Byte, Blue:Byte)
		Color[0] = Red
		Color[1] = Green
		Color[2] = Blue
	End Method

	Function OnPaint(Event:wxEvent)
		Local DrawPanel : TDrawPanel, ..
		      DC        : wxPaintDC
		
		DrawPanel = TDrawPanel(Event.Parent)
		DC        = New wxPaintDC.Create(DrawPanel)
		DrawPanel.PrepareDC(DC)

		Local Colour : wxColour
		Colour = New wxColour.Create(..
			DrawPanel.Color[0], ..
			DrawPanel.Color[1], ..
			DrawPanel.Color[2])
			
		DC.SetBackground(New wxBrush.CreateFromColour(Colour))
		DC.Clear()
		
		DC.Free()
	End Function
End Type

Type TTimer Extends wxTimer
	Method Notify()
		Frame.Panel.SetColor(Rand(0, 255), Rand(0, 255), Rand(0, 255))
		' Frame.Panel.OnPaint(XYZ)
	End Method
End Type


This is my first test. The DrawPanel should redefine its backgroundcolor every 100ms. But how can I release a OnPaint event manually?

And the DrawPanel is not fully redrawn oO