Multiple f_in_box__control...lagging animation

.NET Edition of the F-IN-BOX
chnou
Posts: 2
Joined: Mon Aug 24, 2009 7:00 pm

Multiple f_in_box__control...lagging animation

Postby chnou » Mon Aug 24, 2009 7:15 pm

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

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Mon Aug 24, 2009 7:32 pm

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.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Tue Aug 25, 2009 2:18 pm

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.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

chnou
Posts: 2
Joined: Mon Aug 24, 2009 7:00 pm

Postby chnou » Tue Aug 25, 2009 3:07 pm

Thank you for your fast reply, it works great !

Christopher

dagelmyster
Posts: 5
Joined: Thu Feb 04, 2010 5:00 pm

Postby dagelmyster » Thu Mar 18, 2010 3:31 pm

Could you possibly supply this code for vb.net?

Thanks!


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 1 guest