home *** CD-ROM | disk | FTP | other *** search
- { Project Info.DPR Delphi 2.0 Demos
-
- Description:- Info.Dpr Project:-
-
- Demonstrates the use of:
-
- 1) 'Xresolution'
- 2) 'Yresolution'
- 3) 'ColorDepth'
- 4) 'GetPalColor'
- 5) 'GetPalIndex'
- 6) 'GetColor'
-
- Date of Origin: 15/04/96
- Original Author: Andrew Hutchison
- Modification History:
-
- Date Person Change
- ----------------------------------------------------
- 15/04/96 A Hutchison Created
-
- (c) Copyright Media Architects Inc. 1996.
- All rights reserved. No part of this program may be
- photocopied, reproduced, translated to another programming
- language or transported to any computer system without the
- prior written consent of Media Architects Inc.}
-
- unit UInfo;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, OleCtrls, ImageKnife32, ExtCtrls, Menus;
-
- type
- TForm1 = class(TForm)
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- LoadImage: TMenuItem;
- N1: TMenuItem;
- Exit: TMenuItem;
- Bevel1: TBevel;
- Picbuf1: TPicbuf;
- GroupBox1: TGroupBox;
- GroupBox2: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- Shape: TShape;
- Xpos: TLabel;
- Ypos: TLabel;
- Width: TLabel;
- Height: TLabel;
- BitDepth: TLabel;
- Color: TLabel;
- PalIndex: TLabel;
- PalColor: TLabel;
- OpenDialog: TOpenDialog;
- procedure Picbuf1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Picbuf1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure LoadImageClick(Sender: TObject);
- procedure ExitClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
-
- {-------------------------------------------------------------------------------}
- {Update all captions connected with a Mouse Move Event. Always use calls that
- can be converted to a Valid Caption}
- procedure TForm1.Picbuf1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- {Trap all Non Valid Options}
- try
- {Set X and Y Label Captions - Reflects Mouse Location over Image}
- XPos.Caption := inttostr (Picbuf1.ScreenToImageX(X));
- YPos.Caption := inttostr (Picbuf1.ScreenToImageY(Y));
- {Update all Lables using appropriate IK Calls}
- if Picbuf1.ColorDepth = 24 then
- Color.Caption:= inttostr(Picbuf1.Getcolor(Picbuf1.ScreenToImageX(X),Picbuf1.ScreenToImageY(Y)))
- else {Any Bit depth other than 24 Bit}
- begin
- PalIndex.Caption:=inttostr(Picbuf1.GetPalIndex(Picbuf1.ScreenToImageX(X),Picbuf1.ScreenToImageY(Y)));
- PalColor.Caption:=inttostr(Picbuf1.GetPalColor(Picbuf1.GetPalIndex(Picbuf1.ScreenToImageX(X),Picbuf1.ScreenToImageY(Y))));
- Color.Caption:= inttostr(Picbuf1.GetColor(Picbuf1.ScreenToImageX(X),Picbuf1.ScreenToImageY(Y)));
- end;
- except
- end;
- end;
-
-
- {-------------------------------------------------------------------------------}
- {Update Color swatch Uusing a Mouse Down event}
- procedure TForm1.Picbuf1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- With Shape.Brush do {Reference Shape.Brush}
- Color:= Picbuf1.GetColor(Picbuf1.ScreenToImageX(X),Picbuf1.ScreenToImageY(Y));
- end;
-
-
- {-------------------------------------------------------------------------------}
- {Load Image using Standard Control}
- procedure TForm1.LoadImageClick(Sender: TObject);
- begin
- if OpenDialog.Execute then {Reference Control}
- begin
- Picbuf1.FileName:=OpenDialog.FileName; {Set FileName}
- Picbuf1.Load; {Call Load}
- Width.Caption:=inttostr(Picbuf1.Xresolution); {Caption}
- Height.Caption:=inttostr(Picbuf1.Yresolution); {Caption}
- BitDepth.Caption:=inttostr(Picbuf1.ColorDepth); {Caption}
- end;
- end;
-
-
- {-------------------------------------------------------------------------------}
- {Close Project Down}
- procedure TForm1.ExitClick(Sender: TObject);
- begin
- Halt;
- end;
-
-
- {-------------------------------------------------------------------------------}
- {Set Defaults}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Application.HintPause:=10;
- Application.HintColor:=clAqua;
- end;
-
- procedure TForm1.FormActivate(Sender: TObject);
- begin
- PicBuf1.Filename := '..\images\marybeth.tif';
- PicBuf1.Load;
- end;
-
- end.
-