Reputation: 741
My problem is that I have an application developed in C# and before adding .png backgrounds all the forms are loading smoothly. After adding the backgrounds, the forms are loading much more difficult than before.
What can I possibly do in order to avoid the slow loading of the forms?
Thanks!
Upvotes: 2
Views: 1092
Reputation: 3032
Png format is faster than jpg and bmp.but you must load them at application startup.
Image Backgrund1 = Image.FromFile(@"MyFile1.png");
...
..
.
And in the load event set them to background;
this.BackgroundImage = Background1
Did you test it?
Also you can compress your images with some software such as photoshop -> Save for Web. It
Upvotes: 0
Reputation: 32428
You could add a timer to your form with a delay. Then load the PNGs in the tick event (as well as disabling the timer). That way the form would appear straight-away, but take a few seconds to show the PNG.
You could also try loading the PNGs in the Form_Shown event, although i'm not sure if that occurs after the GUI is displayed.
A final option could be, if appropriate, to load the forms before they're needed.
Upvotes: 1