lcl: don't draw background on TImage with TransparentColor.

Reasons: Transparent property controls only Graphic.Transparent and nothing more. If an image is always transparent (icon, png with alpha, etc) this property controls nothing. This is also delphi compatible behavior (fixes #0011646).

git-svn-id: trunk@16374 -
This commit is contained in:
paul 2008-09-03 03:00:41 +00:00
parent 60daf2ddd1
commit c8f918e694

View File

@ -66,8 +66,9 @@ end;
procedure TCustomImage.SetPicture(const AValue: TPicture); procedure TCustomImage.SetPicture(const AValue: TPicture);
begin begin
if FPicture=AValue then exit; if FPicture=AValue then exit;
FPicture.Assign(AValue); //the OnChange of the picture gets called and //the OnChange of the picture gets called and
// notifies this TCustomImage that something changed. // notifies this TCustomImage that something changed.
FPicture.Assign(AValue);
end; end;
procedure TCustomImage.DoAutoSize; procedure TCustomImage.DoAutoSize;
@ -104,10 +105,8 @@ begin
if (NewWidth>100000) or (NewHeight>100000) then if (NewWidth>100000) or (NewHeight>100000) then
OutOfBounds; OutOfBounds;
if (NewWidth<>Width) or (NewHeight<>Height) if (NewWidth<>Width) or (NewHeight<>Height) then
then begin
SetBounds(Left, Top, NewWidth, NewHeight); SetBounds(Left, Top, NewWidth, NewHeight);
end;
finally finally
EndAutoSizing; EndAutoSizing;
end; end;
@ -124,8 +123,7 @@ procedure TCustomImage.SetTransparent(Value : Boolean);
begin begin
if FTransparent=Value then exit; if FTransparent=Value then exit;
FTransparent := Value; FTransparent := Value;
if (FPicture.Graphic is TBitmap) if (FPicture.Graphic.Transparent <> FTransparent)
and (FPicture.Graphic.Transparent <> FTransparent)
then FPicture.Graphic.Transparent := FTransparent then FPicture.Graphic.Transparent := FTransparent
else PictureChanged(Self); else PictureChanged(Self);
end; end;
@ -153,10 +151,9 @@ begin
InvalidatePreferredSize; InvalidatePreferredSize;
AdjustSize; AdjustSize;
end; end;
if FTransparent Picture.Graphic.Transparent := FTransparent;
then Picture.Graphic.Transparent := True;
end; end;
Invalidate; invalidate;
end; end;
function TCustomImage.DestRect: TRect; function TCustomImage.DestRect: TRect;
@ -228,7 +225,6 @@ procedure TCustomImage.Paint;
var var
R: TRect; R: TRect;
C: TCanvas; C: TCanvas;
BackgroundColor: Integer;
begin begin
// detect loop // detect loop
if FUseParentCanvas then exit; if FUseParentCanvas then exit;
@ -239,23 +235,8 @@ begin
if Picture.Graphic = nil if Picture.Graphic = nil
then Exit; then Exit;
if Picture.Graphic.Transparent and not Transparent
then begin
if Picture.Graphic is TBitmap
then BackgroundColor := TBitmap(Picture.Graphic).TransparentColor
else BackgroundColor := clWhite;
end
else begin
BackgroundColor := clNone;
end;
C := inherited Canvas; C := inherited Canvas;
R := DestRect; R := DestRect;
if BackgroundColor <> clNone
then begin
C.Brush.Color := BackgroundColor;
C.FillRect(R);
end;
C.StretchDraw(R, Picture.Graphic); C.StretchDraw(R, Picture.Graphic);
try try