My application needs to quickly display a number of bitmaps (and Icons), so rather than loading from file when required I load them all into an image list (VCL)
and then extract as required.
But I require the bitmaps to have a transparent background, in this example it is Black.
The problem is that they do not display transparently (I see the bitmaps on a black square)
The image list is setup as follows:-
BkColor = ClBlack
BlendColor = ClNone
Drawing Style = dsTransparent
ImageType = itImage
Masked = false
The following code loads the Imagelist 'ActorImages'
I am using addmasked as this should force transparency ??
The following code creates objects (both types) dynamically from a file stream, and extracts the associated images from the imagelists (one for icons one for bitmaps).
As you can see I have tried to force transparency at this point, still no luck!
Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
and then extract as required.
But I require the bitmaps to have a transparent background, in this example it is Black.
The problem is that they do not display transparently (I see the bitmaps on a black square)
The image list is setup as follows:-
BkColor = ClBlack
BlendColor = ClNone
Drawing Style = dsTransparent
ImageType = itImage
Masked = false
The following code loads the Imagelist 'ActorImages'
I am using addmasked as this should force transparency ??
Code:
procedure TForm1.LoadActors(FName: TFilename);
var Bmp: TBitMap;
Temp: string;
A: integer;
begin
ActorImages.Clear;
Bmp := TBitMap.Create;
for a := 0 to NumberofBMs -1 do
begin
Temp := FName;
Temp := changefileext(Temp,'');
Bmp.LoadFromFile(Temp + inttostr(a)+'.bmp');
ActorImages.AddMasked(Bmp, $00000000);
end;
Bmp.Free;
end;
The following code creates objects (both types) dynamically from a file stream, and extracts the associated images from the imagelists (one for icons one for bitmaps).
As you can see I have tried to force transparency at this point, still no luck!
Code:
constructor TThings.CreateFromStream(Fs : TFileStream );
begin
inherited Create;
ReadFromStream(Fs);
objectico := TImage.create(objectico);
with objectico do
begin
if objtype = inanimate then
begin
Enabled := True;
Width := 32;
Height := 32;
Top := YPos;
Left := XPos;
Form1.ImageList.GetIcon(ImageIndex[0], Picture.Icon);
Tag := index;
OnMouseDown := MouseDown;
OnMouseMove := MouseMove;
OnMouseUp := MouseUp;
Hint := ObjectName;
ShowHint := True;
// PopUpMenu := Menu;
end
else
begin
Enabled := True;
Width := 128;
Height := 128;
Top := 240;
Left := 650;
Form1.ActorImages.GetBitmap(ImageIndex[0], Picture.BitMap);
Picture.Bitmap.TransparentColor := $00000000;
Picture.Bitmap.Transparent := true;
Tag := index;
end
end;
end;
Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain