Page 1 of 1

Multiple f_in_box__control...lagging animation

Posted: Mon Aug 24, 2009 7:15 pm
by chnou
Hello, I created an MFC Application in C# and added 3 f_in_box__control to the Form. I added a JPEG background to the form and added a f_in_box__control_OnPaintStage method and set the 3 f_in_box__control to transparent. When I load the 3 swf files in each f_in_box__control, the animations lags like hell...

I used the f_in_box__control.PutMovieFromStream(ioStream); to load a swf file from my Hard drive and f_in_box__control.FlashMethod_Play(); to play.

I noticed that with one SWF playing there is no lag but as soon as I load and play the two others, theres major lag...

I took the f_in_box__control_OnPaintStage method from the given sample applications.

I hope you can help me. And if possible a simple sample application that demonstrates how to load multiple swf in a form without lag would be perfect !

Thank you for your time.


Christopher

Posted: Mon Aug 24, 2009 7:32 pm
by Softanics
Thank you for your question.

Could you please send me your code to support (at) f-in-box.com to check it?

Thank you in advance.

Posted: Tue Aug 25, 2009 2:18 pm
by Softanics
I've received your code, and I would like to share my idea of how to improve painting. The idea is to replace:

Code: Select all

        public void f_in_box__control_OnPaintStage(object sender, f_in_box__lib.PaintStage stage, System.Drawing.Graphics Canvas)
        {
            if (f_in_box__lib.PaintStage.PrePaint == stage)
            {
                f_in_box__lib.f_in_box__control f_in_box__control = (f_in_box__lib.f_in_box__control)sender;

                using (Bitmap b = new Bitmap(Width, Height))
                {
                    using (Graphics g = Graphics.FromImage(b))
                    {
                        PaintEventArgs pea = new PaintEventArgs(g, new Rectangle(f_in_box__control.Location, f_in_box__control.Size));

                        this.OnPaintBackground(pea);
                        this.OnPaint(pea);

                        Canvas.DrawImage(
                            b,
                            new Rectangle(new Point(0, 0), f_in_box__control.Size),
                            new Rectangle(f_in_box__control.Location, f_in_box__control.Size),
                            GraphicsUnit.Pixel);
                    }
                }
            }
        }


with:

Code: Select all

        private Bitmap b = null;
        private Graphics g = null;

        public void f_in_box__control_OnPaintStage(object sender, f_in_box__lib.PaintStage stage, System.Drawing.Graphics Canvas)
        {
            if (f_in_box__lib.PaintStage.PrePaint == stage)
            {
                f_in_box__lib.f_in_box__control f_in_box__control = (f_in_box__lib.f_in_box__control)sender;

                if (null == b)
                {
                    b = new Bitmap(Width, Height);
                    g = Graphics.FromImage(b);

                    PaintEventArgs pea = new PaintEventArgs(g, new Rectangle(f_in_box__control.Location, f_in_box__control.Size));

                    this.OnPaintBackground(pea);
                    this.OnPaint(pea);
                }

                Canvas.DrawImage(
                    b,
                    new Rectangle(new Point(0, 0), f_in_box__control.Size),
                    new Rectangle(f_in_box__control.Location, f_in_box__control.Size),
                    GraphicsUnit.Pixel);
            }
        }


So what can be painted once, should be painted once :)

Thank you.

Posted: Tue Aug 25, 2009 3:07 pm
by chnou
Thank you for your fast reply, it works great !

Christopher

Posted: Thu Mar 18, 2010 3:31 pm
by dagelmyster
Could you possibly supply this code for vb.net?

Thanks!