Re:Help: Loading a very large bitmap on a form during splash screen
Quote
lr...@mrccos.com (Larry Rose) wrote:
>Hi,
>I've got a program with a very large bitmap (>3MB) that must be loaded onto a
>form. It would be great if that could be done on the window in the background
>while a splash screen occurs.
>The form (Form1) has a TImage, and the bitmap is on disk.
>So, in the onCreate of Form1, I'm doing Image1.LoadFromFile( 'big.bmp' );
>However, it seems that when the splash screen is done, then Form1 gets shown,
>and it takes a few seconds before the bitmap appears.
>I've followed a cookbook splash screen example, and still can't seem to get
>this bitmap to load during the splash screen happening - any clues?
To conserve Windows GDI handles and system resources, VCL doesn't
create handles until they are actually needed. What's probably
happening is the 3MB bitmap gets loaded into memory during the splash
screen time, and then when the main form is shown and the TImage is
told to paint its bitmap, the bitmap handle is created at that moment
from the data in memory. There should be no disk access, but moving
3MB of pixel data around will take some time, thus the pause when the
form first comes up.
Suggestion: Touch the bitmap handle property (read from it)
immediately after loading the bitmap file, to force the object to
create the bitmap handle before the form gets into its display cycle.
-Danny Thorpe