Class TSmartImage (unit Imager)

Inherits from

TGraphicControl

TSmartImage

Constructors


constructor Create(AOwner: TComponent);

procedure DrawTransparentBitmapOnto(Target, Source: TBitmap; XX, YY: Integer; Transp: TColor); var BmpXOr, BmpAnd, BmpInvert, BmpTarget: TBitmap; C: Longint; begin try BmpAnd := Graphics.


Functions

destructor Destroy;


procedure LoadFromFile(const Filename: string);


procedure SaveToFile(const FileName: string);


procedure ClearBitmap;


function GetPalette: HPALETTE;


procedure Paint;


procedure CMColorChanged(var Message: TMessage);


procedure CMParentColorChanged(var Message: TMessage);


procedure CMSysColorChange(var Message: TMessage);


function GetCanvas: TCanvas;


procedure PictureChanged(Sender: TObject);


procedure ResetBitmap;


procedure SetAutoSize(Value: Boolean);


procedure SetBitmap(Value: TBitmap);


procedure SetCenter(Value: Boolean);


procedure SetMaintainAspect(Value: Boolean);


procedure SetPicture(Value: TPicture);


procedure SetStretch(Value: Boolean);

if Transparent and (not Value.

procedure SetTransparent(Value: Boolean);


Properties

property Align :


property AutoSize : Boolean


property Center : Boolean


property DragCursor :

property Color;

property DragMode :


property Enabled :


property MaintainAspect : Boolean


property ParentShowHint :


property Picture : TPicture

property ParentColor;

property PopupMenu :


property ShowHint :


property Stretch : Boolean


property Transparent : Boolean


property Visible :


property Canvas : TCanvas


property Bitmap : TBitmap


Events

event OnClick :


event OnDblClick :


event OnDragDrop :


event OnDragOver :


event OnEndDrag :


event OnMouseDown :


event OnMouseMove :


event OnMouseUp :


Variables

FAutoSize : Boolean;


FBitmap : TBitmap;


FCenter : Boolean;


FMaintainAspect : Boolean;


FPicture : TPicture;


FReserved : Byte;


FStretch : Boolean;


FTransparent : Boolean;



Constructors


constructor Create(AOwner: TComponent);

procedure DrawTransparentBitmapOnto(Target, Source: TBitmap; XX, YY: Integer; Transp: TColor); var BmpXOr, BmpAnd, BmpInvert, BmpTarget: TBitmap; C: Longint; begin try BmpAnd := Graphics.TBitmap.Create; BmpAnd.Width := Source.Width; BmpAnd.Height := Source.Height; BmpAnd.Monochrome := True; C := SetBkColor(Source.Canvas.Handle, ColorToRGB(Transp)); BitBlt(BmpAnd.Canvas.Handle, 0, 0, Source.Width, Source.Height, Source.Canvas.Handle, 0, 0, SRCCOPY); SetBkColor(Source.Canvas.Handle, C); BmpInvert := Graphics.TBitmap.Create; BmpInvert.Width := Source.Width; BmpInvert.Height := Source.Height; BmpInvert.Monochrome := True; BitBlt(BmpInvert.Canvas.Handle, 0, 0, Source.Width, Source.Height, BmpAnd.Canvas.Handle, 0, 0, NOTSRCCOPY); BmpXOr := Graphics.TBitmap.Create; BmpXOr.Width := Source.Width; BmpXOr.Height := Source.Height; BitBlt(BmpXOr.Canvas.Handle, 0, 0, Source.Width, Source.Height, Source.Canvas.Handle, 0, 0, SRCCOPY); BitBlt(BmpXOr.Canvas.Handle, 0, 0, Source.Width, Source.Height, BmpInvert.Canvas.Handle, 0, 0, SRCAND); BmpTarget := TBitmap.Create; BmpTarget.Width := Source.Width; BmpTarget.Height := Source.Height; BitBlt(BmpTarget.Canvas.Handle, 0, 0, Source.Width, Source.Height, Target.Canvas.Handle, XX, YY, SRCCOPY); BitBlt(BmpTarget.Canvas.Handle, 0, 0, Source.Width, Source.Height, BmpAnd.Canvas.Handle, 0, 0, SRCAND); BitBlt(BmpTarget.Canvas.Handle, 0, 0, Source.Width, Source.Height, BmpXOr.Canvas.Handle, 0, 0, SRCINVERT); BitBlt(Target.Canvas.Handle, XX, YY, Source.Width, Source.Height, BmpTarget.Canvas.Handle, 0, 0, SRCCOPY); finally BmpXOr.Free; BmpAnd.Free; BmpInvert.Free; BmpTarget.Free; end; end; *) { TSmartImage


Functions


destructor Destroy;


procedure LoadFromFile(const Filename: string);


procedure SaveToFile(const FileName: string);


procedure ClearBitmap;


function GetPalette: HPALETTE;


procedure Paint;


procedure CMColorChanged(var Message: TMessage);


procedure CMParentColorChanged(var Message: TMessage);


procedure CMSysColorChange(var Message: TMessage);


function GetCanvas: TCanvas;


procedure PictureChanged(Sender: TObject);


procedure ResetBitmap;


procedure SetAutoSize(Value: Boolean);


procedure SetBitmap(Value: TBitmap);


procedure SetCenter(Value: Boolean);


procedure SetMaintainAspect(Value: Boolean);


procedure SetPicture(Value: TPicture);


procedure SetStretch(Value: Boolean);

if Transparent and (not Value.Empty) then begin BMP := TBitmap.Create; Dest := Rect(0, 0, Value.Width, Value.Height); BMP.Width := Dest.Right; BMP.Height := Dest.Bottom; with BMP.Canvas do begin Brush.Color := Color; BrushCopy(Dest, Value, Dest, Value.Canvas.Pixels[0, 0]); end; Bitmap.Assign(BMP); BMP.Free; end else


procedure SetTransparent(Value: Boolean);


Properties


property Align :


property AutoSize : Boolean


property Center : Boolean


property DragCursor :

property Color;


property DragMode :


property Enabled :


property MaintainAspect : Boolean


property ParentShowHint :


property Picture : TPicture

property ParentColor;


property PopupMenu :


property ShowHint :


property Stretch : Boolean


property Transparent : Boolean


property Visible :


property Canvas : TCanvas


property Bitmap : TBitmap


Events


event OnClick :


event OnDblClick :


event OnDragDrop :


event OnDragOver :


event OnEndDrag :


event OnMouseDown :


event OnMouseMove :


event OnMouseUp :


Variables


FAutoSize : Boolean;


FBitmap : TBitmap;


FCenter : Boolean;


FMaintainAspect : Boolean;


FPicture : TPicture;


FReserved : Byte;


FStretch : Boolean;


FTransparent : Boolean;