Einzelnen Beitrag anzeigen

ljmarkus

Registriert seit: 14. Apr 2007
Ort: Göttingen
46 Beiträge
 
Delphi 7 Personal
 
#1

in Byte umrechnen und per string senden

  Alt 2. Mai 2009, 10:32
Hallo.

ich lese die Paintbox aus ob Pixel gesetzt sind. Immer 8 Pixel um es per 1 Byte zusenden.

Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);

var timebuffer: String;

    MyTime: TDateTime;

    Data: array [0..55] of string;

    Bit0,Bit1,Bit2,Bit3,Bit4,Bit5,Bit6,Bit7: byte;

begin

if PaintBox1.Canvas.Pixels[0,0] = clBlack then bit0 := 1 else bit0 := 0;

if PaintBox1.Canvas.Pixels[1,0] = clBlack then bit1 := 1 else bit1 := 0;

if PaintBox1.Canvas.Pixels[2,0] = clBlack then bit2 := 1 else bit2 := 0;

if PaintBox1.Canvas.Pixels[3,0] = clBlack then bit3 := 1 else bit3 := 0;

if PaintBox1.Canvas.Pixels[4,0] = clBlack then bit4 := 1 else bit4 := 0;

if PaintBox1.Canvas.Pixels[5,0] = clBlack then bit5 := 1 else bit5 := 0;

if PaintBox1.Canvas.Pixels[6,0] = clBlack then bit6 := 1 else bit6 := 0;

if PaintBox1.Canvas.Pixels[7,0] = clBlack then bit7 := 1 else bit7 := 0;

if bit0 = 1 then Data[0] := (Data[0] + #$80);//128;

if bit1 = 1 then Data[0] := (Data[0] + #$40);//64;

if bit2 = 1 then Data[0] := (Data[0] + #$20);//32;

if bit3 = 1 then Data[0] := (Data[0] + #$10);//16;

if bit4 = 1 then Data[0] := (Data[0] + #$8);//8;

if bit5 = 1 then Data[0] := (Data[0] + #$4);//4;

if bit6 = 1 then Data[0] := (Data[0] + #$2);

if bit7 = 1 then Data[0] := (Data[0] + #$1);

ComPort1.WriteStr(Data[0]);
end;
leider werden aber mehr als ein Byte gesendet.
Wie und wo habe ich mich da jetzt verzettelt ?

z.b. Wenn alle Pixel gesetzt sind soll ein Hex FF gesendet werden.

Danke, Markus
  Mit Zitat antworten Zitat