mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 20:50:39 +02:00
clean up for TBitmapImage sharing
git-svn-id: trunk@5252 -
This commit is contained in:
parent
b499a159f4
commit
94d066eea6
@ -744,7 +744,7 @@ type
|
|||||||
private
|
private
|
||||||
FAutoReDraw : Boolean;
|
FAutoReDraw : Boolean;
|
||||||
FState: TCanvasState;
|
FState: TCanvasState;
|
||||||
FFont : TFont;
|
FFont: TFont;
|
||||||
FSavedFontHandle: HFont;
|
FSavedFontHandle: HFont;
|
||||||
FPen: TPen;
|
FPen: TPen;
|
||||||
FSavedPenHandle: HPen;
|
FSavedPenHandle: HPen;
|
||||||
@ -752,9 +752,9 @@ type
|
|||||||
FSavedBrushHandle: HBrush;
|
FSavedBrushHandle: HBrush;
|
||||||
FRegion: TRegion;
|
FRegion: TRegion;
|
||||||
FSavedRegionHandle: HRGN;
|
FSavedRegionHandle: HRGN;
|
||||||
FPenPos : TPoint;
|
FPenPos: TPoint;
|
||||||
FCopyMode : TCopyMode;
|
FCopyMode: TCopyMode;
|
||||||
FHandle : HDC;
|
FHandle: HDC;
|
||||||
FOnChange: TNotifyEvent;
|
FOnChange: TNotifyEvent;
|
||||||
FOnChanging: TNotifyEvent;
|
FOnChanging: TNotifyEvent;
|
||||||
FTextStyle: TTextStyle;
|
FTextStyle: TTextStyle;
|
||||||
@ -775,7 +775,6 @@ type
|
|||||||
Procedure SetColor(c: TColor);
|
Procedure SetColor(c: TColor);
|
||||||
Procedure SetBrush(value : TBrush);
|
Procedure SetBrush(value : TBrush);
|
||||||
Procedure SetFont(value : TFont);
|
Procedure SetFont(value : TFont);
|
||||||
procedure SetHandle(NewHandle: HDC);
|
|
||||||
Procedure SetPen(value : TPen);
|
Procedure SetPen(value : TPen);
|
||||||
Procedure SetPenPos(Value : TPoint);
|
Procedure SetPenPos(Value : TPoint);
|
||||||
Procedure SetPixel(X,Y : Integer; Value : TColor);
|
Procedure SetPixel(X,Y : Integer; Value : TColor);
|
||||||
@ -789,6 +788,7 @@ type
|
|||||||
procedure RequiredState(ReqState: TCanvasState);
|
procedure RequiredState(ReqState: TCanvasState);
|
||||||
procedure Changed; virtual;
|
procedure Changed; virtual;
|
||||||
procedure Changing; virtual;
|
procedure Changing; virtual;
|
||||||
|
procedure SetHandle(NewHandle: HDC); virtual;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -1222,16 +1222,15 @@ const
|
|||||||
type
|
type
|
||||||
TBitmapCanvas = class(TCanvas)
|
TBitmapCanvas = class(TCanvas)
|
||||||
private
|
private
|
||||||
FBitmap : TBitmap;
|
FBitmap: TBitmap;
|
||||||
FOldBitmap : HBitmap;
|
FOldBitmap: HBitmap;
|
||||||
FOldPalette : HPALETTE;
|
FOldPalette: HPALETTE;
|
||||||
procedure FreeDC;
|
procedure FreeDC;
|
||||||
protected
|
protected
|
||||||
procedure CreateHandle; override;
|
procedure CreateHandle; override;
|
||||||
public
|
public
|
||||||
constructor Create(ABitmap : TBitmap);
|
constructor Create(ABitmap : TBitmap);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
// TODO: replace this by property BitmapHandle;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1599,6 +1598,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.125 2004/03/02 22:37:36 mattias
|
||||||
|
clean up for TBitmapImage sharing
|
||||||
|
|
||||||
Revision 1.124 2004/03/01 18:02:00 mattias
|
Revision 1.124 2004/03/01 18:02:00 mattias
|
||||||
fixed IsFileExtensionSupported
|
fixed IsFileExtensionSupported
|
||||||
|
|
||||||
|
@ -41,29 +41,25 @@ procedure TBitMapCanvas.CreateHandle;
|
|||||||
var
|
var
|
||||||
DC: HDC;
|
DC: HDC;
|
||||||
begin
|
begin
|
||||||
if FBitmap <> nil then
|
FreeDC;
|
||||||
begin
|
if FBitmap = nil then exit;
|
||||||
FBitmap.HandleNeeded;
|
FBitmap.HandleNeeded;
|
||||||
FreeDC;
|
FBitmap.PaletteNeeded;
|
||||||
FBitmap.PaletteNeeded;
|
DC := CreateCompatibleDC(0);
|
||||||
DC := CreateCompatibleDC(0);
|
|
||||||
|
|
||||||
Assert(False, Format('trace:[TBitmapCanvas.CreateHandle] Got Handle 0x%x', [FBitmap.Handle]));
|
if not FBitmap.HandleAllocated then
|
||||||
|
FOldBitmap := 0
|
||||||
|
else
|
||||||
|
FOldBitmap := SelectObject(DC, FBitmap.Handle);
|
||||||
|
|
||||||
if not FBitmap.HandleAllocated then
|
if FBitmap.FPalette = 0 then
|
||||||
FOldBitmap := 0
|
FOldPalette := 0
|
||||||
else
|
else begin
|
||||||
FOldBitmap := SelectObject(DC, FBitmap.Handle);
|
FOldPalette := SelectPalette(DC, FBitmap.FPalette, True);
|
||||||
|
RealizePalette(DC);
|
||||||
if FBitmap.FPalette = 0 then
|
|
||||||
FOldPalette := 0
|
|
||||||
else begin
|
|
||||||
FOldPalette := SelectPalette(DC, FBitmap.FPalette, True);
|
|
||||||
RealizePalette(DC);
|
|
||||||
end;
|
|
||||||
|
|
||||||
Handle := DC;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Handle := DC;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -79,7 +75,6 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TControlCanvas.FreeDC
|
Method: TControlCanvas.FreeDC
|
||||||
Params: None
|
Params: None
|
||||||
@ -91,8 +86,8 @@ procedure TBitmapCanvas.FreeDC;
|
|||||||
var
|
var
|
||||||
OldHandle: HBITMAP;
|
OldHandle: HBITMAP;
|
||||||
begin
|
begin
|
||||||
if FHandle <> 0 then
|
if not HandleAllocated then exit;
|
||||||
begin
|
if FBitmap<>nil then begin
|
||||||
if FOldBitmap <> 0 then begin
|
if FOldBitmap <> 0 then begin
|
||||||
SelectObject(FHandle, FOldBitmap);
|
SelectObject(FHandle, FOldBitmap);
|
||||||
FOldBitmap:=0;
|
FOldBitmap:=0;
|
||||||
@ -104,6 +99,8 @@ begin
|
|||||||
OldHandle := FHandle;
|
OldHandle := FHandle;
|
||||||
Handle := 0;
|
Handle := 0;
|
||||||
DeleteDC(OldHandle);
|
DeleteDC(OldHandle);
|
||||||
|
end else begin
|
||||||
|
Handle:=0;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -112,6 +109,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.9 2004/03/02 22:37:36 mattias
|
||||||
|
clean up for TBitmapImage sharing
|
||||||
|
|
||||||
Revision 1.8 2004/02/05 16:28:38 mattias
|
Revision 1.8 2004/02/05 16:28:38 mattias
|
||||||
fixed unsharing TBitmap
|
fixed unsharing TBitmap
|
||||||
|
|
||||||
|
@ -22,14 +22,10 @@ begin
|
|||||||
FSaveStreamType:=bnNone;
|
FSaveStreamType:=bnNone;
|
||||||
if FDIBHandle <> 0 then
|
if FDIBHandle <> 0 then
|
||||||
begin
|
begin
|
||||||
//TODO:write this function
|
|
||||||
//DeselectBitmap(FDIBHandle);
|
|
||||||
DeleteObject(FDIBHandle);
|
DeleteObject(FDIBHandle);
|
||||||
FDIBHandle := 0;
|
FDIBHandle := 0;
|
||||||
end;
|
end;
|
||||||
FreeHandle;
|
FreeHandle;
|
||||||
//TODO Write CloseHandle
|
|
||||||
//if FDIB.dshSection <> 0 then CloseHandle(FDIB.dshSection);
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -54,21 +50,15 @@ end;
|
|||||||
|
|
||||||
procedure TBitmapImage.FreeHandle;
|
procedure TBitmapImage.FreeHandle;
|
||||||
begin
|
begin
|
||||||
if (FHandle <> 0) and (FHandle <> FDIBHandle) then
|
|
||||||
begin
|
|
||||||
//TODO: Once written, remove comment below
|
|
||||||
//DeselectBitmap(FHandle);
|
|
||||||
DeleteObject(FHandle);
|
|
||||||
end;
|
|
||||||
if FMaskHandle <> 0 then
|
if FMaskHandle <> 0 then
|
||||||
begin
|
begin
|
||||||
//TODO: Once written, remove comment below
|
|
||||||
//DeselectBitmap(FMaskHandle);
|
|
||||||
DeleteObject(FMaskHandle);
|
DeleteObject(FMaskHandle);
|
||||||
FMaskHandle := 0;
|
FMaskHandle := 0;
|
||||||
end;
|
end;
|
||||||
//TODO: Once written, remove comment below
|
if (FHandle <> 0) and (FHandle <> FDIBHandle) then
|
||||||
//InternalDeletePalette(FPalette);
|
begin
|
||||||
|
DeleteObject(FHandle);
|
||||||
|
end;
|
||||||
FHandle := 0;
|
FHandle := 0;
|
||||||
FPalette := 0;
|
FPalette := 0;
|
||||||
end;
|
end;
|
||||||
|
@ -469,6 +469,7 @@ end;
|
|||||||
procedure TCustomImageList.GetBitmap(Index: Integer; Image: TBitmap);
|
procedure TCustomImageList.GetBitmap(Index: Integer; Image: TBitmap);
|
||||||
begin
|
begin
|
||||||
if (FCount = 0) or (Image = nil) then Exit;
|
if (FCount = 0) or (Image = nil) then Exit;
|
||||||
|
//writeln('TCustomImageList.GetBitmap Index=',Index,' Image=',HexStr(Cardinal(Image),8),' Bitmap=',HexStr(Cardinal(FImageList.Items[Index]),8));
|
||||||
Image.Assign(TBitMap(FImageList.Items[Index]));
|
Image.Assign(TBitMap(FImageList.Items[Index]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1165,6 +1166,9 @@ end;
|
|||||||
{
|
{
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.29 2004/03/02 22:37:36 mattias
|
||||||
|
clean up for TBitmapImage sharing
|
||||||
|
|
||||||
Revision 1.28 2004/03/01 23:45:33 marc
|
Revision 1.28 2004/03/01 23:45:33 marc
|
||||||
* Patch from olivier GUILBAUD and Colin Western
|
* Patch from olivier GUILBAUD and Colin Western
|
||||||
* fixed addcopy
|
* fixed addcopy
|
||||||
|
Loading…
Reference in New Issue
Block a user