I have a bitmap with an array of fixed size images. Depending on the
state I wish to show I copy one of the images to a bitmap. In Delphi
this works ok with CopyRect. However, CopyRect does not seem to work in
Lazarus so I used MaskBlt instead. The problem is that I can not set the
transparency of this copied image. I tried turning off the Transparent
property and then turning it on, Using TransparentMode and
TransparentColor - all with no result. The only way I managed to get
transparency was to save the new image to a memorystream, read it back
and then set the Transparent property. I am sure this is not the correct
way. Can someone send me a better solution please?
Here is the code:
procedure TLinkCanvas.LoadImage(bmp : TBitmap; imageNum, index : integer);
var
w : integer;
{$ifdef fpc}
ms :TMemoryStream;
{$endif}
begin
w := currImages^[0].Height;
with bmp do
begin
Width := w;
Height := w;
{$ifdef fpc}
MaskBlt(Canvas.Handle, 0, 0, w, w,
currImages^[imageNum].Canvas.Handle, index*w, 0,
MaskHandle, index*w, 0);
ms := TMemoryStream.Create;
SaveToStream(ms);
ms.Position := 0;
LoadFromStream(ms);
ms.Free();
Transparent := true;
{$else}
Canvas.CopyRect(Canvas.ClipRect, currImages^[imageNum].Canvas,
Rect(index*w, 0, (index+1)*w, w));
{$endif}
end;
end;
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives