unit Unit1;
interface
uses
Windows, Messages, ...
type
TForm1 =
class(TForm)
PaintBox1: TPaintBox;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
GBBitmap: TBitmap;
procedure ReadGBCamPixels;
procedure ZeichneGBBitmap;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
GBCamPixelGrauW :
Array [0..127, 0..127]
of Byte;
procedure TForm1.FormCreate(Sender: TObject);
begin
GBBitmap := TBitmap.Create;
// Virt. Bitmap erzeugen
GBBitmap.Width := 128;
// Grösse festlegen
GBBitmap.Height := 128;
GBBitmap.Pixelformat := pf8bit;
// 256 Farben od. Grauwerte
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
GBBitmap.Free;
// Virt. Bitmap freigeben
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
// Das Bitmap in der PBox zeichen (lassen beim verschieben des Frensters etc.)
PaintBox1.Canvas.Draw(0, 0, GBBitmap);
end;
procedure TForm1.ReadGBCamPixels;
var
x,y : Integer;
begin
// Einlesen der Cam Werte aus der GBCam.
// ...
// ...
// ...
// for y := 0 to 128 do
// for x := 0 to 128 do
// GBCamPixelGrauW[x, y] := ...
end;
procedure TForm1.ZeichneGBBitmap;
var
x,y : Integer;
begin
// Hiier das Bitmap miit den Farbpixeln zeichnen
for y := 0
to 128
do
for x := 0
to 128
do
GBBitmap.Canvas.Pixels[x, y] :=
RGB(GBCamPixelGrauW[x, y], GBCamPixelGrauW[x, y], GBCamPixelGrauW[x, y]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// The Action
ReadGBCamPixels;
ZeichneGBBitmap;
PaintBox1.Repaint;
end;
end.