How to clear the display?

Hi,

I wrote a program to display a sequence of the bitmap files. The
display is perfect. However, if I open another sequence of the bitmap
files which have the smaller size, then the display not only has the
new bitmap files, but it also has part of the previous images. It is
very annoying. I am using the dc buffer and paint event to display the
image. Are there any way to fix this problem?

Thanks

Frank

You are probably creating new instances of wx.StaticBitmap instead of creating only one instance and calling its SetBitmap method to change the image.

···

On 11/2/11 6:30 PM, yixiaodafang@gmail.com wrote:

Hi,

I wrote a program to display a sequence of the bitmap files. The
display is perfect. However, if I open another sequence of the bitmap
files which have the smaller size, then the display not only has the
new bitmap files, but it also has part of the previous images. It is
very annoying. I am using the dc buffer and paint event to display the
image. Are there any way to fix this problem?

--
Robin Dunn
Software Craftsman

It sounds to me like the OP isn't using wx.StaticBimap, but rather drawing to the Window with a DC.

If I'm right, all you need to do is call:

DC.Clear()

before drawing the new bitmap

If you set the BackgroundColor first, Clear() will set it to that color.

However, you might want to get a little fancier and change the size of the Window to match the bitmap your using -- then you can place in your window with a sizer and some spaces, if the parent window is bigger than it needs to be.

-Chris

···

On 11/2/11 7:03 PM, Robin Dunn wrote:

I wrote a program to display a sequence of the bitmap files. The
display is perfect. However, if I open another sequence of the bitmap
files which have the smaller size, then the display not only has the
new bitmap files, but it also has part of the previous images. It is
very annoying. I am using the dc buffer and paint event to display the
image. Are there any way to fix this problem?

You are probably creating new instances of wx.StaticBitmap instead of
creating only one instance and calling its SetBitmap method to change
the image.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Use dc.Clear or dc.DrawRectangle before you draw the image.

Toni

···

On Thu, 03 Nov 2011 02:30:49 +0100, yixiaodafang@gmail.com <yixiaodafang@gmail.com> wrote:

Hi,

I wrote a program to display a sequence of the bitmap files. The
display is perfect. However, if I open another sequence of the bitmap
files which have the smaller size, then the display not only has the
new bitmap files, but it also has part of the previous images. It is
very annoying. I am using the dc buffer and paint event to display the
image. Are there any way to fix this problem?

Thanks you very much for the helpful response.

The SetBacground(wx.Brush(wx.BLACK)) and the dc.Clear() solved my
problem.

Frank

···

On Nov 2, 10:06 pm, Chris Barker <Chris.Bar...@noaa.gov> wrote:

On 11/2/11 7:03 PM, Robin Dunn wrote:

>> I wrote a program to display a sequence of the bitmap files. The
>> display is perfect. However, if I open another sequence of the bitmap
>> files which have the smaller size, then the display not only has the
>> new bitmap files, but it also has part of the previous images. It is
>> very annoying. I am using the dc buffer and paint event to display the
>> image. Are there any way to fix this problem?

> You are probably creating new instances of wx.StaticBitmap instead of
> creating only one instance and calling its SetBitmap method to change
> the image.

It sounds to me like the OP isn't using wx.StaticBimap, but rather
drawing to the Window with a DC.

If I'm right, all you need to do is call:

DC.Clear()

before drawing the new bitmap

If you set the BackgroundColor first, Clear() will set it to that color.

However, you might want to get a little fancier and change the size of
the Window to match the bitmap your using -- then you can place in your
window with a sizer and some spaces, if the parent window is bigger than
it needs to be.

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Bar...@noaa.gov

Oops, you're probably right. That's what I get for not reading to the end. Most of the time when there are messages that start like this one they are creating multiple instances of wx.StaticBitmap.

···

On 11/2/11 10:06 PM, Chris Barker wrote:

On 11/2/11 7:03 PM, Robin Dunn wrote:

I wrote a program to display a sequence of the bitmap files. The
display is perfect. However, if I open another sequence of the bitmap
files which have the smaller size, then the display not only has the
new bitmap files, but it also has part of the previous images. It is
very annoying. I am using the dc buffer and paint event to display the
image. Are there any way to fix this problem?

You are probably creating new instances of wx.StaticBitmap instead of
creating only one instance and calling its SetBitmap method to change
the image.

It sounds to me like the OP isn't using wx.StaticBimap, but rather
drawing to the Window with a DC.

--
Robin Dunn
Software Craftsman