Dcb: Delphi Version
{*****************************************************************************
* *
* Dcb.dpr *
* DcbU.pas *
* *
* This program demonstrates the Fastgraph for Windows direct color bitmap *
* display functions. *
* *
*****************************************************************************}
unit DcbU;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Menus, FGWin;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
DrawDCB: TMenuItem;
ClipDCB: TMenuItem;
RevDCB: TMenuItem;
FlipDCB: TMenuItem;
PutDCB: TMenuItem;
Exit1: TMenuItem;
procedure AppOnActivate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DrawDCBClick(Sender: TObject);
procedure ClipDCBClick(Sender: TObject);
procedure FlipDCBClick(Sender: TObject);
procedure RevDCBClick(Sender: TObject);
procedure PutDCBClick(Sender: TObject);
procedure ExitClick(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$J+}
{$R *.DFM}
const
vbWidth = 320;
vbHeight = 240;
{ 40x20 high color bitmapped image of a bird }
Bird : array [1..800] of word = (
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0821,$0821,$0000,$0821,$0000,$0821,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0821,$FFFF,$0821,$AD55,$0821,$AD55,$0821,$0821,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0821,$FFFF,$FFFF,$0821,$AD55,$0821,$AD55,$0821,$FFFF,
$0821,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0821,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$FFFF,$0821,$FFFF,$FFFF,
$0821,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0821,$0821,$0821,
$0821,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$FFFF,$0821,$FFFF,$0821,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0821,$0821,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0821,$FFFF,$FFFF,$FFFF,
$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,
$0000,$0000,$0821,$0821,$0821,$0821,$0821,$AD55,$0821,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0821,$0821,$FFFF,$FFFF,$0821,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0000,
$0000,$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0821,$FFFF,$FFFF,$0821,$FFFF,$FFFF,
$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0000,
$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0821,$FFFF,$0821,$FFFF,$FFFF,$0821,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0000,
$0821,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0821,$FFFF,$FFFF,$0821,$FFFF,$FFFF,$0821,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0821,
$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0821,$FFFF,$0821,$FFFF,$FFFF,$0821,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$0821,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0821,$0821,$FFFF,$FFFF,$0821,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$FFFF,$FFFF,
$0821,$FFFF,$0821,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0821,$FFFF,$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$FFFF,$FFFF,
$FFFF,$FFFF,$0821,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0821,$0821,$0821,$0821,$0000,$0000,$0000,$0000,$0000,
$0821,$FFFF,$FFFF,$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,
$FFFF,$0821,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0821,$AD55,$AD55,$AD55,$AD55,$0821,$0821,$0821,$0821,$0000,
$0821,$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$FFFF,$FFFF,$FFFF,$0821,
$0821,$0821,$0821,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0821,$AD55,$AD55,$AD55,$AD55,$AD55,$AD55,$AD55,$0821,
$FFFF,$FFFF,$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$0821,$FFFF,$FFFF,$FFFF,$0821,$AD55,
$AD55,$AD55,$AD55,$0821,$0821,$0821,$0821,$0821,$0821,$0000,
$0000,$0000,$0821,$0821,$0821,$0821,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$0821,$A800,$A800,$0821,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0821,$0821,$0821,$0821,
$0821,$0821,$0821,$0821,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$A800,$FFFF,$FFFF,$0821,$0821,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0821,$0821,$FFFF,$FFFF,$FFFF,$FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$0821,$0821,$0821,
$0821,$FFFF,$FFFF,$FFFF,$0821,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
$0000,$0000,$0000,$0000,$0000,$0000,$0821,$0821,$0821,$0821,
$0821,$0821,$0821,$0821,$0821,$0821,$0821,$0000,$0000,$0000,
$0000,$0821,$0821,$0821,$0000,$0000,$0000,$0000,$0000,$0000);
var
dc : hDC;
hPal : hPalette;
hVB : integer;
cxClient, cyClient : integer;
procedure TForm1.AppOnActivate(Sender: TObject);
begin
fg_realize(hPal);
Invalidate;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
fg_realize(hPal);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
dc := GetDC(Form1.Handle);
fg_setdc(dc);
hPal := fg_defpal;
fg_realize(hPal);
fg_vbinit;
fg_vbdepth(16);
hVB := fg_vballoc(WIDTH,HEIGHT);
fg_vbopen(hVB);
fg_vbcolors;
fg_setcolorrgb(85,255,85);
fg_fillpage;
Application.OnActivate := AppOnActivate;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.FormResize(Sender: TObject);
begin
cxClient := ClientWidth;
cyClient := ClientHeight;
Invalidate;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
fg_vbclose;
fg_vbfree(hVB);
fg_vbfin;
DeleteObject(hPal);
ReleaseDC(Form1.Handle,dc);
end;
procedure TForm1.DrawDCBClick(Sender: TObject);
begin
fg_fillpage;
fg_move(vbWidth div 2 - 20,vbHeight div 2 + 10);
fg_drawdcb(Bird,40,20);
fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.ClipDCBClick(Sender: TObject);
begin
fg_fillpage;
fg_move(-20,vbHeight div 2 + 10);
fg_clipdcb(Bird,40,20);
fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.RevDCBClick(Sender: TObject);
begin
fg_fillpage;
fg_move(vbWidth div 2 - 20,vbHeight div 2 + 10);
fg_revdcb(Bird,40,20);
fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.FlipDCBClick(Sender: TObject);
begin
fg_fillpage;
fg_move(vbWidth-20,vbHeight div 2 + 10);
fg_flipdcb(Bird,40,20);
fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.PutDCBClick(Sender: TObject);
begin
fg_fillpage;
fg_move(vbWidth div 2 - 20,vbHeight div 2 + 10);
fg_putdcb(Bird,40,20);
fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.ExitClick(Sender: TObject);
begin
Close;
end;
end.
|