MIMAGE

Top  Previous  Next

{

TMonoImage   : Monokróm Timage komponens (Delphi 1.0)

StellaSOFT

}

unit Mimage;

 

interface

uses

SysUtils, WinTypes, WinProcs, Messages, Classes,

Graphics, ExtCtrls, Controls, Forms;

 

Type

TMonoImage = class(TImage)

private

  FMonochrome     : boolean;

  FChange         : TNotifyEvent;

  procedure SetMonochrome(Value:boolean);

  procedure Change(Sender:TObject);

protected

  BaseColorImage: TImage;      {alapkép betöltéséhez szines alapbitmap}

  BaseMonoImage: TImage;       {alapkép betöltéséhez monochrome alapbitmap}

public

  constructor Create(AOwner:TComponent);override;

  destructor Destroy;override;

published

  Property Monochrome : boolean read FMonochrome write SetMonochrome ;

  Property OnChange : TNotifyEvent read FChange write FChange;

end;

 

procedure Register;

 

implementation

 

procedure Register;

begin

RegisterComponents('AL',[TMonoImage]);

end;

 

constructor TMonoImage.Create(AOwner:TComponent);

var i: integer;

begin

   inherited Create(AOwner);

   BaseColorImage:= TImage.Create(Self);

   BaseMonoImage:= TImage.Create(Self);

   BaseMonoImage.Picture.Bitmap.Monochrome:=True;

   Picture.OnChange := Change;

   FMonochrome := False;

   Width:=100; Height:=100;

end;

 

destructor TMonoImage.Destroy;

var i: integer;

begin

   BaseColorImage.Free;

   BaseMonoImage.Free;

   inherited Destroy;

end;

 

procedure TMonoImage.SetMonochrome(Value:boolean);

begin

If (BaseColorImage<>nil) then begin

   FMonochrome:=Value;

   Picture.Bitmap.Monochrome:=Value;

{     Canvas.CopyMode:=cmSrcCopy;

   If Monochrome then begin

      Canvas.Brush.Color:=ClSilver;

      Canvas.Font.Color:=ClWhite;

      Canvas.StretchDraw(ClientRect,BaseMonoImage.Picture.Graphic)

   end else

      Canvas.StretchDraw(ClientRect,BaseColorImage.Picture.Graphic);}

   Picture.Bitmap.Monochrome:=False;

   Invalidate;

end;

end;

 

procedure TMonoImage.Change(Sender:TObject);

begin

If Picture.graphic<>nil then begin

   Case Monochrome of

   True: begin

         BaseColorImage.Picture.Graphic.Width := Picture.Width;

         BaseColorImage.Picture.Graphic.Height := Picture.Height;

         Canvas.Draw(0,0,BaseColorImage.Picture.Graphic);

         end;

   False:begin

         end;

   end;

   Canvas.StretchDraw(ClientRect,BaseColorImage.Picture.Graphic);

end;

If Assigned(FChange) then FChange(Self);

{  inherited Change;}

end;

 

end.