TTransImage component
(C) Copyright 1998 R.Schultz, mus303@yahoo.com
Free for NON-commercial use only !!

  05-18-98 ver. 1.0 - initial release, comments please !

  * Based on TTransSplash - my transparent splash screen-
    component. But this one is much more complete.

  * Displays a masked image, rendering it transparently
    against any underlying components, or just your form.

  * The source code is free as well, but you'll have to e-mail
    me for the password. I don't want your money. I just want to
    know who has the source code, to make sure you share any
    further development of this component with me =)

  * The component will be installed under the "Additional"
    page. If you had the source code, you could change this =)

  * This component is, and will remain, FREE.

  * The next version will have "blue-screening" capabilities, i.e.
    you won't need a transparency mask, but blue colours will be
    masked out - you'll have a choice of using red, green or
    blue masking. Also, a new attribute will be added, which will
    enable you to use TTransImage just like TTransSplash, for
    transparent splash screens. (i.e. the whole form completely
    invisible)

Copy TransImg.DCU and TransImg.DCR to your Delphi\LIB directory,
install the new component into your user library, then open the
sample project TestTTransImage.DPR - have fun ! =)

--- As per request: here's ...
--- "How To Make Suitable Images" (example using photoshop)

What the component does, is it masks out parts of the Picture,
according to a second picture, a grayscale picture, PictureMask.
Wherever there is BLACK on the mask, the pixels in Picture are
transparent, wherever there is WHITE, the pixels are visible,
and wherever there is GREY, the picture is SEMI-transparent !!
So let's say you want to create a picture of a square, casting
a shadow onto your form - transparently ! =) ..

Step 1 : Create a new layer. Draw a square, plain and simple.
         Make it a BLACK square.
Step 2 : Copy your layer to a new layer, layer 2. Make sure this
         layer goes BENEITH layer 1. Now smooth this layer, using
         gaussian smoothing, by two or three pixels, then adjust
         the transparency of this layer to about 50%.
Step 3 : Select layer 1, make the background layer invisible,
         then do a "Merge Visible" so that your two layers merge
         into one.
Step 4 : Using "Duplicate Image", create a second copy of your
         entire picture.
Step 5 : The first copy of your picture - colour the background
         BLACK. Now all you'll see a is a big old black picture.
         This is your Picture. Flatten and save as a BMP. 
Step 6 : The second copy of you picture, select your only layer,
         and load it's transparency as a selection. Save this
         selection to a channel. Trash your layer, so all you
         have is the empty background. Go to the new channel,
         select all, then copy, then trash the channel. Go back
         to your layers, paste what you just copied, flatten the
         image. This is your PictureMask. Save it as a BMP.

Now pop into Delphi and load your new picture and picturemask, see
the magic =) A piece of advice for all you hardcore photoshoppers,
and graphic maniacs out there -- be careful when you create your
image. This is NOT as easy as you may think at first. In order to
get good results, you have use your head ! It can be really hard
to get your picture and picturemask to create the right kind of
impression, because antialiasing can become quite inaccurate or
even wrong, if for example you have a green circle on a blue back-
ground in your picture - it's antialiased as green towards blue,
and you will get blue edges on your TransImage. See the problem ?
So plan it well, and get good results =)

--- How to make a transparent splash screen
--- (this will be automated in the next version)

Step 1 : Drop a TTransImage onto a form, and load up the Picture
         and PictureMask for your splash screen. Give this
         component the Name "Splash".
Step 2 : Adjust the properties of your form:
         set BorderIcons = []
         set BorderStyle = bsNone
         set FormStyle = fsStayOnTop
         set Position = poScreenCenter
Step 3 : Write this OnCreate event for your form:
         ClientWidth:=Splash.Width;
         ClientHeight:=Splash.Height;
         Brush.Style:=bsClear;

Maybe you'll want to write an OnClick event for "Splash", to
make the splash screen disappear when it's clicked. Most of
the time though, splash screens just time out and close
themselves. You can write a little delay procedure like this:

procedure TMyForm.Delay(ms: Integer);
var
  FirstTickCount: LongInt;
begin
  FirstTickCount:=GetTickCount;
  repeat
    Application.ProcessMessages;
  until ((GetTickCount-FirstTickCount)>=LongInt(ms));
end;

You should put "procedure Delay(ms: Integer);" under your
form's private declarations as well.
NOTE: the ms variable specifies the delay in 1/1000 seconds.

--- Make it work like a real splash screen
--- (something my component CAN'T do)

If you want to make your splash screen work like a real
splash screen, then it should display when your program
is initializing/loading/etc. and stay for a minimum period
of time, and then close itself. Here's what you can do:

Step 1 : Alter your project source:
         begin
           Application.Initialize;
           Application.CreateForm(TSplashForm, SplashForm);
           SplashForm.Show;
           SplashForm.Refresh;
           // Now create the rest of your forms here !
           Splash.Close;
           Application.Run;
         end.
Step 2 : In the Private section of your SplashForm, add a variable
         "Start" of type Cardinal.
Step 3 : Write a FormCloseQuery event for your SplashForm:
         begin
           Repeat Until GetTickCount-Start > 5000;
           // NOTE: again, 5000*1/1000 sec = 5 seconds delay ..
           CanClose := True;
         end;
Step 4 : Write a FormShow event for your SplashForm:
         begin
           Start := GetTickCount;
         end;

This should give you something to work with for a while, although
I think I've done most of the work for you allready ;)

