mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 23:23:48 +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
|
||||
TheDialog: TGraphicPropertyEditorForm;
|
||||
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
|
||||
//debugln('TButtonGlyphPropEditor.Edit');
|
||||
ABitmap := TBitmap(GetObjectValue(TBitmap));
|
||||
TheDialog := TGraphicPropertyEditorForm.Create(nil);
|
||||
try
|
||||
If not ABitmap.Empty then begin
|
||||
if not ABitmap.Empty then begin
|
||||
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;
|
||||
if (TheDialog.ShowModal = mrOK) then begin
|
||||
If TheDialog.Preview.Picture.Graphic <> nil then begin
|
||||
if TheDialog.Modified then begin
|
||||
LoadBitmap;
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
ABitmap.Width:=0;
|
||||
ABitmap.Height:=0;
|
||||
if TheDialog.Modified then begin
|
||||
ABitmap.Assign(TheDialog.Preview.Picture.Graphic);
|
||||
Modified;
|
||||
end;
|
||||
Modified;
|
||||
end;
|
||||
finally
|
||||
TheDialog.Free;
|
||||
|
@ -1049,6 +1049,7 @@ type
|
||||
FMaskHandle: HBITMAP;
|
||||
FPalette: HPALETTE;
|
||||
FDIBHandle: HBITMAP;// output device independent handle
|
||||
FBitmapCanvas: TCanvas; // current canvas selected into
|
||||
FSaveStream: TMemoryStream;
|
||||
FSaveStreamClass: TFPCustomImageWriterClass;
|
||||
FSaveStreamType: TBitmapNativeType;
|
||||
@ -1063,6 +1064,7 @@ type
|
||||
destructor Destroy; override;
|
||||
function HandleAllocated: boolean; override;
|
||||
function GetHandleType: TBitmapHandleType;
|
||||
property BitmapCanvas: TCanvas read FBitmapCanvas write FBitmapCanvas;
|
||||
property SaveStream: TMemoryStream read FSaveStream write FSaveStream;
|
||||
property SaveStreamType: TBitmapNativeType read FSaveStreamType write FSaveStreamType;
|
||||
property SaveStreamClass: TFPCustomImageWriterClass read FSaveStreamClass write FSaveStreamClass;
|
||||
|
@ -88,6 +88,9 @@ begin
|
||||
IntfImage.Free;
|
||||
end;
|
||||
Changed(Self);
|
||||
end else if Source = nil then begin
|
||||
FreeSaveStream;
|
||||
SetWidthHeight(0,0);
|
||||
end else
|
||||
inherited Assign(Source);
|
||||
end;
|
||||
@ -657,8 +660,8 @@ begin
|
||||
|
||||
UnshareImage(false);
|
||||
if UseSize and (Size = 0) then begin
|
||||
Width:=0;
|
||||
Height:=0;
|
||||
FreeSaveStream;
|
||||
SetWidthHeight(0,0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
|
@ -45,6 +45,9 @@ begin
|
||||
if FBitmap = nil then exit;
|
||||
FBitmap.HandleNeeded;
|
||||
FBitmap.PaletteNeeded;
|
||||
if FBitmap.FImage.BitmapCanvas <> nil then
|
||||
TBitmapCanvas(FBitmap.FImage.BitmapCanvas).FreeDC;
|
||||
FBitmap.FImage.BitmapCanvas := Self;
|
||||
DC := CreateCompatibleDC(0);
|
||||
|
||||
FOldBitmap := 0;
|
||||
|
Loading…
Reference in New Issue
Block a user