Re: Nasty flickering by OnPaint Graphics.Invalidate by Mark
Mark
Wed Nov 26 14:25:20 CST 2003
I tried the following:
a counter was added so that the Bitmap Methode is only call once:
public override void OnPanel(int i_Event)
{
i_Test++;
base.OnPanel(i_Event);
if (i_New_Game == 1)
Setup_Basic_Logic();
if (i_Test == 1)
OnCreateWorkScreenBitmap();
if (sbStatusBarMainFrame != null)
sbStatusBarMainFrame.Text = "TryGame_Cards.OnPanel("+i_Test+")";
}
This means the Bitmap is only being repainted without being build again.
It still flickers.
I then turned off the OnMouseMove/Up/Down Events and took out the counter.
(i.e. OnPaint runs when resizing)
no flicker !
Only the when the events are turned on where the Invalidate() is done does
it flicker (for the Card only a flicker on the Card being moved).
Mark Johnson, Berlin Germany
mj10777@mj10777.de
"Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> schrieb im Newsbeitrag
news:ue%231dQFtDHA.1224@TK2MSFTNGP09.phx.gbl...
> Offhand I don't see anything glaring, though you are createing a graphics
> object a lot, and I tend to create and use one and only one for all my
work.
> I have a pretty complex control (a dial-indicator gauge) that essentailly
> uses triple-buffering by generating a static image for the areas that
don't
> change, then drawing it and the changing stuff to another image, which I
> then blit to the screen. I've run several instances on a 640x480 display
> without any flicker at all.
>
> --
> Chris Tacke, eMVP
> Co-Founder and Advisory Board Member
> www.OpenNETCF.org
> ---
> Windows CE Product Manager
> Applied Data Systems
> www.applieddata.net
>
>
> "Mark Johnson" <mj10777@mj10777.de> wrote in message
> news:3fc4fcfc$0$27621$9b4e6d93@newsread4.arcor-online.net...
> > public virtual void OnPaint(object sender,
> > System.Windows.Forms.PaintEventArgs e)
> > {
> > p_Graphics = e.Graphics;
> > OnPanel(0); // This calls OnCreateWorkScreenBitmap()
> >
> > p_Graphics.DrawImage(bmp_Work[i_Work_Screen],0,0);
> > }
> > public void OnCreateWorkScreenBitmap()
> > { // First create our Bitmap and the Graphic to Draw
> > bmp_Work[i_Work_Empty] = new
> >
>
Bitmap(bmp_Work[i_Work_Back].Size.Width,bmp_Work[i_Work_Back].Size.Height);
> > Graphics gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Empty]);
> > gs_Graphics.Clear(cl_Work);
> > gs_Graphics.Dispose();
> > if (bmp_Work[i_Work_Screen]!=null)
> > bmp_Work[i_Work_Screen].Dispose();
> > bmp_Work[i_Work_Screen] = new
> > Bitmap((i_Screen_Width_Diff+i_Screen_Width_Real),
> >
> > (i_Screen_Height_Diff+i_Screen_Height_Real));
> > gs_Graphics = Graphics.FromImage(bmp_Work[i_Work_Screen]);
> > gs_Graphics.Clear(cl_Work);
> >
> > // a lot of code chosing which Bitmap at what position should be painted
> > into the Image with the local Graphics, then
> >
> > // This Paints Work Bitmap at the desired Position
> > #if !COMPACT
> > gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work);
> > #else
> > // For Compact the Bitmap cannot be resised
> > Rectangle srcRect = new
> > Rectangle(0,0,rt_Work.Width,rt_Work.Height+10);
> >
> >
>
gs_Graphics.DrawImage(bmp_Work[i_Work_Paint],rt_Work,srcRect,GraphicsUnit.Pi
> > xel);
> > #endif
> > gs_Graphics.Dispose();
> > } // public void OnCreateWorkScreenBitmap()
> >
> > I can send you the full code if you give a e-mail adress.
> >
> > Mark Johnson, Berlin Germnay
> > mj10777@mj10777.de
> >
> >
> >
> > "Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> schrieb im
Newsbeitrag
> > news:%23QeO58EtDHA.2260@TK2MSFTNGP09.phx.gbl...
> > > I'd have to see your code, but I've done quite a bit of flicker-free
> > drawing
> > > with the CF.
> > >
> > > --
> > > Chris Tacke, eMVP
> > > Co-Founder and Advisory Board Member
> > > www.OpenNETCF.org
> > > ---
> > > Windows CE Product Manager
> > > Applied Data Systems
> > > www.applieddata.net
> > >
> > >
> > > "Mark Johnson" <mj10777@mj10777.de> wrote in message
> > > news:3fc4f1af$0$20254$9b4e6d93@newsread2.arcor-online.net...
> > > > Using: VS 2003 NET C# for Framework and Framework Compact
> > > > Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version
on
> > > > OnMouseMove
> > > > Problem : The affected drawing Area by Invalidate (or
> > > Invalidate(Rectangle))
> > > > flickers in a nasty way when repainting.
> > > >
> > > > This does not happen in the Solitare (PC + WinCe) Versions a well as
> in
> > a
> > > > Card game where I have the C++ Source.
> > > >
> > > > The use of an empty OnPaintBackground brings no visable results.
> > > >
> > > > The OnPaint calls a Method, which builds a new Bitmap with a local
> > > Graphics.
> > > > When finished OnPaint does one DrawImage Command (flicker).
> > > >
> > > > OnPaint is painting to a Panel.
> > > >
> > > > Is this a Framework problem ?
> > > >
> > > > Can a flicker free Painting only be done with some sort of Win-API.
> > > > - Goal is for this Class to run with the same code on both Systems.
> > > >
> > > > If yes, what would it look like inside a Framework program ?
> > > >
> > > > This seems to the last major problem (as of yet) that I have in
> > realising
> > > a
> > > > game programm
> > > > and it would be very nice if this problem could be solved.
> > > >
> > > > Thank you for any help
> > > >
> > > > Mark Johnson, Berlin Germany
> > > > mj10777@mj10777.de
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>