mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-05 16:35:57 +02:00
fix bug #773: cleanup buttonglyph property editor, implement assigning nil to tbitmap, clear bitmap completely by removing saved stream
git-svn-id: trunk@7980 -
This commit is contained in:
parent
b230df103f
commit
3bb8fa7c33
@ -447,65 +447,19 @@ procedure TButtonGlyphPropEditor.Edit;
|
|||||||
var
|
var
|
||||||
TheDialog: TGraphicPropertyEditorForm;
|
TheDialog: TGraphicPropertyEditorForm;
|
||||||
ABitmap: TBitmap;
|
ABitmap: TBitmap;
|
||||||
|
|
||||||
Procedure LoadBitmap;
|
|
||||||
var
|
|
||||||
ext : String;
|
|
||||||
TempBitmap: TBitmap;
|
|
||||||
begin
|
|
||||||
Ext := ExtractFileExt(TheDialog.FileName);
|
|
||||||
if (CompareText(Ext, '.xpm') = 0)
|
|
||||||
or (CompareText(Ext, '.bmp') = 0) then begin
|
|
||||||
If FileExists(TheDialog.FileName) then begin
|
|
||||||
TempBitmap := TBitmap.Create;
|
|
||||||
try
|
|
||||||
// try to load
|
|
||||||
TempBitmap.LoadFromFile(TheDialog.FileName);
|
|
||||||
// no exception -> loading ok
|
|
||||||
ABitmap.Assign(TempBitmap);
|
|
||||||
finally
|
|
||||||
TempBitmap.Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
ABitmap.Assign(TheDialog.Preview.Picture.Graphic);
|
|
||||||
{ABitmap.Width := TheDialog.Preview.Picture.Graphic.Width;
|
|
||||||
ABitmap.Height := TheDialog.Preview.Picture.Graphic.Height;
|
|
||||||
With ABitmap.Canvas do begin
|
|
||||||
Brush.Color := clWhite;
|
|
||||||
FillRect(Rect(0, 0, ABitmap.Width, ABitmap.Height));
|
|
||||||
Draw(0, 0, TheDialog.Preview.Picture.Graphic);
|
|
||||||
end;}
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//debugln('TButtonGlyphPropEditor.Edit');
|
//debugln('TButtonGlyphPropEditor.Edit');
|
||||||
ABitmap := TBitmap(GetObjectValue(TBitmap));
|
ABitmap := TBitmap(GetObjectValue(TBitmap));
|
||||||
TheDialog := TGraphicPropertyEditorForm.Create(nil);
|
TheDialog := TGraphicPropertyEditorForm.Create(nil);
|
||||||
try
|
try
|
||||||
If not ABitmap.Empty then begin
|
if not ABitmap.Empty then begin
|
||||||
TheDialog.Preview.Picture.Assign(ABitmap);
|
TheDialog.Preview.Picture.Assign(ABitmap);
|
||||||
{With TheDialog.Preview.Picture.Bitmap do begin
|
|
||||||
Width := ABitmap.Width;
|
|
||||||
Height := ABitmap.Height;
|
|
||||||
Canvas.Brush.Color := clWhite;
|
|
||||||
Canvas.FillRect(Rect(0, 0, ABitmap.Width, ABitmap.Height));
|
|
||||||
Canvas.Draw(0, 0, ABitmap);
|
|
||||||
end;}
|
|
||||||
end;
|
end;
|
||||||
if (TheDialog.ShowModal = mrOK) then begin
|
if (TheDialog.ShowModal = mrOK) then begin
|
||||||
If TheDialog.Preview.Picture.Graphic <> nil then begin
|
if TheDialog.Modified then begin
|
||||||
if TheDialog.Modified then begin
|
ABitmap.Assign(TheDialog.Preview.Picture.Graphic);
|
||||||
LoadBitmap;
|
Modified;
|
||||||
end;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
ABitmap.Width:=0;
|
|
||||||
ABitmap.Height:=0;
|
|
||||||
end;
|
end;
|
||||||
Modified;
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
TheDialog.Free;
|
TheDialog.Free;
|
||||||
|
@ -1049,6 +1049,7 @@ type
|
|||||||
FMaskHandle: HBITMAP;
|
FMaskHandle: HBITMAP;
|
||||||
FPalette: HPALETTE;
|
FPalette: HPALETTE;
|
||||||
FDIBHandle: HBITMAP;// output device independent handle
|
FDIBHandle: HBITMAP;// output device independent handle
|
||||||
|
FBitmapCanvas: TCanvas; // current canvas selected into
|
||||||
FSaveStream: TMemoryStream;
|
FSaveStream: TMemoryStream;
|
||||||
FSaveStreamClass: TFPCustomImageWriterClass;
|
FSaveStreamClass: TFPCustomImageWriterClass;
|
||||||
FSaveStreamType: TBitmapNativeType;
|
FSaveStreamType: TBitmapNativeType;
|
||||||
@ -1063,6 +1064,7 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function HandleAllocated: boolean; override;
|
function HandleAllocated: boolean; override;
|
||||||
function GetHandleType: TBitmapHandleType;
|
function GetHandleType: TBitmapHandleType;
|
||||||
|
property BitmapCanvas: TCanvas read FBitmapCanvas write FBitmapCanvas;
|
||||||
property SaveStream: TMemoryStream read FSaveStream write FSaveStream;
|
property SaveStream: TMemoryStream read FSaveStream write FSaveStream;
|
||||||
property SaveStreamType: TBitmapNativeType read FSaveStreamType write FSaveStreamType;
|
property SaveStreamType: TBitmapNativeType read FSaveStreamType write FSaveStreamType;
|
||||||
property SaveStreamClass: TFPCustomImageWriterClass read FSaveStreamClass write FSaveStreamClass;
|
property SaveStreamClass: TFPCustomImageWriterClass read FSaveStreamClass write FSaveStreamClass;
|
||||||
|
@ -88,6 +88,9 @@ begin
|
|||||||
IntfImage.Free;
|
IntfImage.Free;
|
||||||
end;
|
end;
|
||||||
Changed(Self);
|
Changed(Self);
|
||||||
|
end else if Source = nil then begin
|
||||||
|
FreeSaveStream;
|
||||||
|
SetWidthHeight(0,0);
|
||||||
end else
|
end else
|
||||||
inherited Assign(Source);
|
inherited Assign(Source);
|
||||||
end;
|
end;
|
||||||
@ -657,8 +660,8 @@ begin
|
|||||||
|
|
||||||
UnshareImage(false);
|
UnshareImage(false);
|
||||||
if UseSize and (Size = 0) then begin
|
if UseSize and (Size = 0) then begin
|
||||||
Width:=0;
|
FreeSaveStream;
|
||||||
Height:=0;
|
SetWidthHeight(0,0);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -45,6 +45,9 @@ begin
|
|||||||
if FBitmap = nil then exit;
|
if FBitmap = nil then exit;
|
||||||
FBitmap.HandleNeeded;
|
FBitmap.HandleNeeded;
|
||||||
FBitmap.PaletteNeeded;
|
FBitmap.PaletteNeeded;
|
||||||
|
if FBitmap.FImage.BitmapCanvas <> nil then
|
||||||
|
TBitmapCanvas(FBitmap.FImage.BitmapCanvas).FreeDC;
|
||||||
|
FBitmap.FImage.BitmapCanvas := Self;
|
||||||
DC := CreateCompatibleDC(0);
|
DC := CreateCompatibleDC(0);
|
||||||
|
|
||||||
FOldBitmap := 0;
|
FOldBitmap := 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user