Checked that out. What I need is a dirty simple button to resize the glyph to the button dimensions, without having to edit the actual image to create the 4 glyphs, or to write the code to load the image at runtime. So, I created a new component, based on TBGRASpeedButton code to do just that. It's simple and works for me.
The code is below. If you find it useful I can send you the lrs file for the lazarus component button image.
Fox
unit BGRAResizeSpeedButton;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Buttons, LResources, Forms,
Controls, Graphics, Dialogs, BGRASpeedButton, BGRABitmap;
type
TBGRAResizeSpeedButton = class(TBGRASpeedButton)
private
{ Private declarations }
FBGRA: TBGRABitmap;
protected
{ Protected declarations }
function DrawGlyph(ACanvas: TCanvas; const AClient: TRect;
const AOffset: TPoint; AState: TButtonState; ATransparent: boolean;
BiDiFlags: longint): TRect; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
end;
procedure Register;
implementation
function TBGRAResizeSpeedButton.DrawGlyph(ACanvas: TCanvas; const AClient: TRect;
const AOffset: TPoint; AState: TButtonState; ATransparent: boolean;
BiDiFlags: longint): TRect;
begin
if Glyph = nil then Exit;
Result:=AClient;
if Assigned(Glyph) and Not Glyph.Empty then
begin
FBGRA.Assign(Glyph);
BGRAReplace(FBGRA,FBGRA.Resample(Self.Width-6,Self.Height-6));
if (AState = bsDown) or (Down = True) then
FBGRA.Draw(ACanvas, 4, 4, False)
else
FBGRA.Draw(ACanvas, 3, 3, False);
end;
end;
constructor TBGRAResizeSpeedButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FBGRA := TBGRABitmap.Create;
end;
destructor TBGRAResizeSpeedButton.Destroy;
begin
FBGRA.Free;
inherited Destroy;
end;
procedure Register;
begin
// {$I bgraresizespeedbutton_icon.lrs}
RegisterComponents('BGRA Controls',[TBGRAResizeSpeedButton]);
end;
end.