Results 1 to 10 of 10

Thread: VS2005 + image rendering optimization...

  1. #1
    Newbie Aldaris's Avatar
    Join Date
    Nov 2005
    Location
    Trois-Rivières, QC
    Posts
    28

    VS2005 + image rendering optimization...

    Hi guys!

    I am developping my own media center software in C# with Visual Studio 2005. It is going well, I programmed all the engine to generate my forms dynamically from an xml file(the skin), but now that it works, the problems I was suspecting from the beginning happened!

    When the form loads and shows up on the screen, every control arrives one after the other, kinda slow... And it is the same thing on each OnPaint of the form...

    I am using Image.FromFile(filename); to preload my images and when I create my form, I create the controls from the list of controls I got from the xml file. I don't think the problem comes from here since it is loaded before the OnPaint, and alse because the problem happens on every OnPaint after the form is created...

    So my question is : Does anybody have encountered this problem, and is there a way to make the controls refresh faster!!??

    Thank you!

  2. #2
    Phone Control Moderator zorro's Avatar
    Join Date
    Mar 2004
    Location
    Munich, Germany
    Posts
    1,902
    Maybe you have some repeated call to invalidate your form while you're painting the controls.
    You should do a Debug.WriteLine each time you're in OnPaint to find that out.

    Loading the image from file is ok if you don't do that in OnPaint. Another thing to mention is the image size. If it's resized during the painting it may cost valueable time.

    Maybe you could post a snippet of your OnPaint routine.
    Skinning to go... VisualDesigner2!

  3. #3
    Newbie Aldaris's Avatar
    Join Date
    Nov 2005
    Location
    Trois-Rivières, QC
    Posts
    28
    In fact, I don't have any code in my OnPaint method for now... it's all done automatically by the base class (System.Windows.Forms).

    Today, I tried to remove the background image to check it this could be the problem, and the result is positive! As soon as I removed the background image, the others controls, begans to refresh normally!

    So now my question is, is there a special way to control the refresh of the background image to make it faster?

    Since the image is 800x600 and 414ko, I will try to drop the quality of the image to get a smaller size when I get the time... we'll see if it does something!

  4. #4
    Newbie Aldaris's Avatar
    Join Date
    Nov 2005
    Location
    Trois-Rivières, QC
    Posts
    28
    nop, no effect at all!

  5. #5
    Newbie
    Join Date
    Sep 2003
    Location
    Finland
    Posts
    31
    Hi!

    I've had same problem, and I just tested below and it seems much faster.

    protected override void OnPaintBackground(PaintEventArgs e)
    {
    // if backgroundimage is set, use it
    if (BackgroundImage != null)
    {
    e.Graphics.DrawImage(BackgroundImage, e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel);
    }
    else
    {
    // else paint with backcolor
    using (SolidBrush brush = new SolidBrush(BackColor))
    {
    e.Graphics.FillRectangle(brush, e.ClipRectangle);
    }
    }
    }

    Looks like that originally forms background paint isn't very efficient...

    But this only works when backgroundimage isn't scaled.

    vvog

  6. #6
    Maximum Bitrate DeltaFX's Avatar
    Join Date
    Sep 2004
    Location
    France
    Posts
    499
    Can't you set your form as Doublebuffered ? Basically it repaints in background then swap display.
    Now Galileo is real. Muhahahahaha :p

  7. #7
    Newbie Aldaris's Avatar
    Join Date
    Nov 2005
    Location
    Trois-Rivières, QC
    Posts
    28
    My form is already set as DoubleBuffered, but it didn't changed anything...

    And thank you vvog for the code, I tried it very fast, but I didn't see any difference, I'll try to test it more when I get some time. Do you override only the onpaint of the form, or the others images on top of that too?

    Thanx
    The Car : Nissan Sentra SE-R Spec V 2003
    The CarPC : Via M10k - 256mb - sb Live 5.1 - lilliput 7''
    Media Center status : 33%
    Car Installation status : 33%
    WorkLog : http://mp3car.com/vbulletin/showthread.php?t=77258

  8. #8
    Newbie Aldaris's Avatar
    Join Date
    Nov 2005
    Location
    Trois-Rivières, QC
    Posts
    28
    This time I took the time to test it, and it is very positive!

    We can still see the images refresh, but it's a lot faster than before, and it's very acceptable!

    Thanx alot for your help vvog, I was stocked on this bug for a while!

    See you around!
    The Car : Nissan Sentra SE-R Spec V 2003
    The CarPC : Via M10k - 256mb - sb Live 5.1 - lilliput 7''
    Media Center status : 33%
    Car Installation status : 33%
    WorkLog : http://mp3car.com/vbulletin/showthread.php?t=77258

  9. #9
    Constant Bitrate
    Join Date
    Sep 2005
    Posts
    121
    using GDI it will be very slow... why not try using DirectX? its quite simple to use and increases rendering performance many times over!

  10. #10
    Newbie
    Join Date
    Feb 2006
    Posts
    3
    you could try...

    Code:
    Public Declare Function LockWindowUpdate Lib "user32" (ByVal Handle As Long) As Long
    
    
    LockWindowUpdate(Me.Handle.ToInt64)
    
    //do painting
    
    LockWindowUpdate(0&)

Similar Threads

  1. [REVIEW] In-Bumper Rear-view camera
    By RoyN in forum General Hardware Discussion
    Replies: 104
    Last Post: 12-30-2006, 03:42 PM
  2. Help w/ backup, restore, or image drive/disk for recovery
    By ITL in forum Software & Software Development
    Replies: 6
    Last Post: 10-25-2005, 09:33 AM
  3. Replies: 10
    Last Post: 07-28-2005, 03:29 PM
  4. Lilliput no image
    By linzhang in forum LCD/Display
    Replies: 6
    Last Post: 11-02-2004, 09:02 AM
  5. DWW-7VGA won't display image
    By guf in forum LCD/Display
    Replies: 0
    Last Post: 05-08-2004, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •