AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

in Byte umrechnen und per string senden

Ein Thema von ljmarkus · begonnen am 2. Mai 2009 · letzter Beitrag vom 2. Mai 2009
 
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
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:40 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz