From caf7b07e05010d4beeaa6a530fd0b48f52dc0fea Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 31 Aug 2008 08:42:07 +0000 Subject: [PATCH] lcl: added RawImageNeeded to the TIconImage. Now accessing of the Canvas for the just added image works. partially fixes #0011983 git-svn-id: trunk@16325 - --- lcl/graphics.pp | 1 + lcl/include/icon.inc | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/lcl/graphics.pp b/lcl/graphics.pp index 885e2bc659..837e24b680 100644 --- a/lcl/graphics.pp +++ b/lcl/graphics.pp @@ -1424,6 +1424,7 @@ type FPalette: HPALETTE; function GetPalette: HPALETTE; protected + procedure RawImageNeeded(ADescOnly: Boolean); public constructor Create(AFormat: TPixelFormat; AHeight, AWidth: Word); constructor Create(const AImage: TRawImage); diff --git a/lcl/include/icon.inc b/lcl/include/icon.inc index 2acf2751dc..89e074467f 100644 --- a/lcl/include/icon.inc +++ b/lcl/include/icon.inc @@ -210,6 +210,40 @@ begin Result := FPalette end; +procedure TIconImage.RawImageNeeded(ADescOnly: Boolean); +var + ImagePtr: PRawImage; + Flags: TRawImageQueryFlags; +begin + ImagePtr := @FImage; + if ImagePtr^.Description.Format <> ricfNone + then begin + // description valid + if ADescOnly then Exit; + if (ImagePtr^.Data <> nil) and (ImagePtr^.DataSize > 0) then Exit; + if ImagePtr^.Description.Width = 0 then Exit; // no data + if ImagePtr^.Description.Height = 0 then Exit; // no data + end; + + if FHandle <> 0 + then begin + if ADescOnly + or not RawImage_FromBitmap(ImagePtr^, FHandle, FMaskHandle) + then ImagePtr^.Description := GetDescriptionFromBitmap(FHandle); + Exit; + end; + + case PixelFormat of + pf1bit: Flags := [riqfMono, riqfMask]; + pf4bit, + pf8bit: Flags := [riqfRGB, riqfMask, riqfPalette]; + pf32bit: Flags := [riqfRGB, riqfMask, riqfAlpha]; + else + Flags := [riqfRGB, riqfMask]; + end; + ImagePtr^.Description := QueryDescription(Flags, Width, Height); +end; + function TIconImage.ReleaseHandle: HBITMAP; begin Result := Handle; @@ -472,14 +506,20 @@ function TCustomIcon.GetRawImagePtr: PRawImage; begin if FCurrent = -1 then Result := nil - else Result := @TIconImage(TSharedIcon(FSharedImage).FImages[FCurrent]).FImage; + else begin + TIconImage(TSharedIcon(FSharedImage).FImages[FCurrent]).RawImageNeeded(False); + Result := @TIconImage(TSharedIcon(FSharedImage).FImages[FCurrent]).FImage; + end; end; function TCustomIcon.GetRawImageDescriptionPtr: PRawImageDescription; begin if FCurrent = -1 then Result := nil - else Result := @TIconImage(TSharedIcon(FSharedImage).FImages[FCurrent]).FImage.Description; + else begin + TIconImage(TSharedIcon(FSharedImage).FImages[FCurrent]).RawImageNeeded(True); + Result := @TIconImage(TSharedIcon(FSharedImage).FImages[FCurrent]).FImage.Description; + end; end; function TCustomIcon.GetTransparent: Boolean;