View Single Post
Old 08-11-2013, 06:51 AM
ogi_dws ogi_dws is offline
Join Date: Jul 2013
Posts: 1
Default How to change DirectDraw surface bitmap

Hi I'm fairly new to DirectDraw and I currently writing a simple app where the main loop draws a surface using DrawFast method, it looks something like this:

frm.backbuffer.DrawFast(Control.MousePosition.X, Control.MousePosition.Y, frm.MySurface, DrawFastFlags.DoNotWait Or DrawFastFlags.SourceColorKey)

the image I'm drawing is a bitmap loaded into the memory, here's initialization of the surface:

MySurface = New Surface(bmpImage, New SurfaceDescription, GraphicsCard)

The problem here is that the 'bmpImage' is changing while the program runs and I don't know how to update this changes into the sprite surface. I want to note that I'm NOT trying to draw an animated sprite, so using a bitmap image with few frames on it is not a solution - I'm drawing a bitmap that is constantly changing.
What I'm doing now to update the surface is restoring the whole surface every time when it is drawn with this method:

Public Sub RestoreSurfaces()
MySurface = New Surface(_BB, New SurfaceDescription, GraphicsCard)
Dim ck As ColorKey = New ColorKey
MySurface.SetColorKey(ColorKeyFlags.SourceDraw, ck)
ck = Nothing
Catch ex As Exception
End Try

I'm wondering is it a good way to update the surface image like that, or this is very slow and bad solution, if there is better solution, please let me know about it, thank you.
Reply With Quote