mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 23:08:05 +02:00
lcl: graphic changes
- don't create dummy mask for icon if image.MaskBitsPerPixel = 0 - win32: create dummy mask for icon if no mask is present since windows cannot live without any mask - force Change at correct place of TIcon.AssignImage - clear not only saved stream on TRasterImage.LoadFromStream but all handles too since they are not valid after loading another data to an image git-svn-id: trunk@16397 -
This commit is contained in:
parent
41d7c28b6b
commit
196b1d0098
@ -1184,7 +1184,7 @@ type
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
procedure Clear; override;
|
||||
procedure BeginUpdate(ACanvasOnly: Boolean = False);
|
||||
procedure EndUpdate;
|
||||
procedure EndUpdate(AStreamIsValid: Boolean = False);
|
||||
procedure FreeImage;
|
||||
function BitmapHandleAllocated: boolean; virtual; abstract;
|
||||
function MaskHandleAllocated: boolean; virtual; abstract;
|
||||
|
@ -311,12 +311,14 @@ begin
|
||||
else
|
||||
if Source is TRasterImage
|
||||
then begin
|
||||
BeginUpdate;
|
||||
Clear;
|
||||
|
||||
with TRasterImage(Source) do
|
||||
Self.Add(PixelFormat, Height, Width);
|
||||
|
||||
AssignImage(TRasterImage(Source));
|
||||
EndUpdate;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
@ -620,7 +622,10 @@ begin
|
||||
if MaskHandleAllocated then exit;
|
||||
|
||||
ImagePtr := GetRawImagePtr;
|
||||
if (ImagePtr = nil) or (ImagePtr^.Description.Format = ricfNone) then Exit;
|
||||
if (ImagePtr = nil) or
|
||||
(ImagePtr^.Description.Format = ricfNone) or
|
||||
(ImagePtr^.Description.MaskBitsPerPixel = 0) then
|
||||
Exit;
|
||||
|
||||
MaskImage.Init;
|
||||
MaskImage.Description := ImagePtr^.Description.GetDescriptionFromMask;
|
||||
@ -1203,8 +1208,8 @@ begin
|
||||
if FSharedImage.FHandle <> 0 then Exit;
|
||||
|
||||
IconInfo.fIcon := True;
|
||||
IconInfo.hbmMask := MaskHandle;
|
||||
IconInfo.hbmColor := BitmapHandle;
|
||||
IconInfo.hbmMask := MaskHandle;
|
||||
FSharedImage.FHandle := WidgetSet.CreateIconIndirect(@IconInfo);
|
||||
end;
|
||||
|
||||
|
@ -252,7 +252,7 @@ begin
|
||||
DestCanvas.Changed;
|
||||
end;
|
||||
|
||||
procedure TRasterImage.EndUpdate;
|
||||
procedure TRasterImage.EndUpdate(AStreamIsValid: Boolean = False);
|
||||
begin
|
||||
if FUpdatecount = 0
|
||||
then raise EInvalidGraphicOperation.Create(rsRasterImageEndUpdate);
|
||||
@ -262,7 +262,8 @@ begin
|
||||
|
||||
if not FUpdateCanvasOnly
|
||||
then FreeCanvasContext;
|
||||
FreeSaveStream;
|
||||
if not AStreamIsValid
|
||||
then FreeSaveStream;
|
||||
Changed(Self);
|
||||
end;
|
||||
|
||||
@ -417,12 +418,11 @@ var
|
||||
WorkStream: TMemoryStream;
|
||||
OldPos, NewSize: Int64;
|
||||
begin
|
||||
BeginUpdate;
|
||||
UnshareImage(False);
|
||||
Clear; // clear old saved stream, allocated handles, etc
|
||||
if ASize = 0
|
||||
then begin
|
||||
Clear;
|
||||
Exit;
|
||||
end;
|
||||
then Exit;
|
||||
|
||||
WorkStream := nil;
|
||||
try
|
||||
@ -431,7 +431,6 @@ begin
|
||||
OldPos := AStream.Position;
|
||||
WorkStream.CopyFrom(AStream, ASize);
|
||||
WorkStream.Position := 0;
|
||||
FreeSaveStream;
|
||||
ReadStream(WorkStream, ASize);
|
||||
NewSize := WorkStream.Position;
|
||||
if NewSize < ASize
|
||||
@ -448,8 +447,7 @@ begin
|
||||
// if something went wrong, free the workstream
|
||||
WorkStream.Free;
|
||||
end;
|
||||
if FUpdateCount = 0
|
||||
then Changed(Self);
|
||||
EndUpdate(True);
|
||||
end;
|
||||
|
||||
function TRasterImage.GetRawImage: TRawImage;
|
||||
|
@ -934,7 +934,7 @@ end;
|
||||
function TWin32WidgetSet.CreateIconIndirect(IconInfo: PIconInfo): HICON;
|
||||
var
|
||||
bmp: Windows.TBitmap;
|
||||
hbm: HBITMAP;
|
||||
hbm1, hbm2: HBITMAP;
|
||||
SrcDataSize, DataSize: PtrUInt;
|
||||
SrcData, Data: PByte;
|
||||
Res: Boolean;
|
||||
@ -965,19 +965,31 @@ begin
|
||||
|
||||
if Res then
|
||||
begin
|
||||
hbm := CreateBitmap(bmp.bmWidth, bmp.bmHeight shl 1, bmp.bmPlanes, 1, Data);
|
||||
hbm1 := CreateBitmap(bmp.bmWidth, bmp.bmHeight shl 1, bmp.bmPlanes, 1, Data);
|
||||
IconInfo^.hbmColor := 0;
|
||||
IconInfo^.hbmMask := hbm;
|
||||
IconInfo^.hbmMask := hbm1;
|
||||
end;
|
||||
|
||||
FreeMem(Data);
|
||||
end
|
||||
else
|
||||
hbm := 0;
|
||||
hbm1 := 0;
|
||||
|
||||
if (IconInfo^.hbmMask = 0) and (IconInfo^.hbmColor <> 0) and (GetObject(IconInfo^.hbmColor, SizeOf(bmp), @bmp) = SizeOf(bmp)) then
|
||||
begin
|
||||
hbm2 := CreateBitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes, 1, nil);
|
||||
IconInfo^.hbmMask := hbm2;
|
||||
end
|
||||
else
|
||||
hbm2 := 0;
|
||||
|
||||
Result := Windows.CreateIconIndirect(IconInfo);
|
||||
|
||||
if hbm <> 0 then
|
||||
DeleteObject(hbm);
|
||||
if hbm1 <> 0 then
|
||||
DeleteObject(hbm1);
|
||||
|
||||
if hbm2 <> 0 then
|
||||
DeleteObject(hbm2);
|
||||
end;
|
||||
|
||||
function TWin32WidgetSet.CreatePatternBrush(ABitmap: HBITMAP): HBRUSH;
|
||||
|
Loading…
Reference in New Issue
Block a user