RFB Protokoll (VNC)

Übersicht BlitzMax, BlitzMax NG Allgemein

Neue Antwort erstellen

 

Phlox

Betreff: RFB Protokoll (VNC)

BeitragMo, Jun 13, 2011 22:49
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi Community,


Ich schreibe derzeit an einem VNC-Server. Wie einige vielleicht wissen, benutzt VNC das remote framebuffer protocol (RFB). Da wird zunächst initialisiert, die Protokollversion ausgehandelt, Passwortabfrage usw. und dann sendet der Server dem Client das ServerInit Paket.

Das RFB Protokoll ist hier erklärt:
http://www.realvnc.com/docs/rfbproto.pdf

Ich bin schon bei 6.3.2 (Seite 17) und verstehe absolut gar nichts mehr.

Dies muss in einen Stream geschrieben werden.

Also, framebuffer-width ist kein Problem und framebuffer-height auch nicht.
Dann kommt PIXEL_FORMAT - da liegt das Problem.

Zitat:
Server-pixel-format specifies the server’s natural pixel format. This pixel format will be used unless the client requests a different format using the SetPixelFormat message (section 6.4.1).

Ok, verstanden.

Zitat:
Bits-per-pixel is the number of bits used for each pixel value on the wire.
This must be greater than or equal to the depth which is the number of useful bits in the pixel value.

Wenn ich für Rot, Grün und Blau immer 0-255 haben kann, ist das 8, richtig?
Und was ist dann depth? Usueful bits in pixel value? Gibt es denn nicht-useful bits?

Zitat:
Currently bits-per-pixel must be 8, 16 or 32 — less than 8-bit pixels are not yet supported.

Klar.

Zitat:
Big-endian-flag is non-zero (true) if multi-byte pixels are interpreted as big endian. Of course this is meaningless for 8 bits-per-pixel.

Klar. Aber warum Big Endian? oO
Naja, betrifft mich ja nicht.

Zitat:
If true-colour-flag is non-zero (true) then the last six items specify how to extract the red, green and blue intensities from the pixel value.

Ich nehme mal an, bei mir 1.

Zitat:
Red-max is the maximum red value (= 2^n-1, where n is the number of bits used for red). Note this value is always in big endian order.

Also 255 in Big Endian? Wie rechnet man das um in BlitzMax?

Zitat:
Red-shift is the number of shifts needed to get the red value in a pixel to the least significant bit. Green-max, green-shift and blue-max, blue-shift are similar for green and blue.

Öhm..?

Zitat:
For example, to find the red value (between 0 and red-max) from a given pixel, do the following:
• Swap the pixel value according to big-endian-flag (e.g. if big-endian-flag is zero (false) and host byte order is big endian, then swap).
• Shift right by red-shift.
• AND with red-max (in host byte order).

Das hat es nicht besser gemacht..

Zitat:
If true-colour-flag is zero (false) then the server uses pixel values which are not directly composed from the red, green and blue intensities, but which serve as indices into a colour map. Entries in the colour map are set by the server using the SetColourMapEntries message (section 6.5.2).

Ok, das brauche ich nicht.

Also, kann mir jemand red-max, green-max, blue-max, red-shift, green-shift und blue-shift erklären?
Padding sollte ja wohl egal sein (einfach 3x WriteByte t.stream,0).

Also das funktioniert nicht:
BlitzMax: [AUSKLAPPEN]
' Send ServerInit
WriteShort t.stream,framebuffer_width
WriteShort t.stream,framebuffer_height
' ServerPixelFormat====
WriteByte t.stream,8' Bits per pixel
WriteByte t.stream,framebuffer_depth' Depth
WriteByte t.stream,0' Big endian flag
WriteByte t.stream,1' True color flag
Local bendstream:TStream=BigEndianStream(t.stream)
WriteShort bendstream,255' red-max
WriteShort bendstream,255' green-max
WriteShort bendstream,255' blue-max
WriteByte t.stream,0' red shift
WriteByte t.stream,7' green shift
WriteByte t.stream,15' blue shift
' Write padding (3 bytes)
WriteByte t.stream,0
WriteByte t.stream,0
WriteByte t.stream,0
' =====================
WriteInt t.stream,Len(framebuffer_name)
WriteString t.stream,framebuffer_name



TIA
Phlox
  • Zuletzt bearbeitet von Phlox am Di, Mai 28, 2013 10:59, insgesamt einmal bearbeitet

Noobody

BeitragMo, Jun 13, 2011 23:17
Antworten mit Zitat
Benutzer-Profile anzeigen
Phlox hat Folgendes geschrieben:
Wenn ich für Rot, Grün und Blau immer 0-255 haben kann, ist das 8, richtig?
Und was ist dann depth? Usueful bits in pixel value? Gibt es denn nicht-useful bits?

Wenn du für Rot, Grün und Blau Werte von 0-255 hast, besitzt jeder Farbkanal 8 Bits - der gesamte Pixel aber 3*8 = 24 Bits (da ja jeder Pixel Rot, Grün und Blau hat).

Jetzt ist es aber so, dass du für Bits-per-pixel nur 8, 16 oder 32 Bits angeben kannst (um das Auslesen zu vereinfachen), daher musst du da 32 Bits angeben (da grösser als 24 Bit) und dafür bei Depth die Anzahl tatsächlich benutzter (=useful) Bits angeben (also 24).

Phlox hat Folgendes geschrieben:
Klar. Aber warum Big Endian? oO
Naja, betrifft mich ja nicht.

Doch, tut es. Du sendest ja jeden Pixel als Integer (da Bits-per-pixel 32 ist), daher ist die Reihenfolge der Bytes entscheidend. Ich bin grade nicht sicher, ob Big Endian oder Little Endian in BMax-Streams standardmässig benutzt werden, aber du kannst den Endian spezifisch mit der Benutzung von LittleEndianStream oder BigEndianStream festlegen. Einfach dann das Endian-Flag entsprechend setzen.

Phlox hat Folgendes geschrieben:
Ich nehme mal an, bei mir 1.

Ja, da du ansonsten eine Farbpalette benutzen müsstest, was ein wenig mühsamer ist.

Phlox hat Folgendes geschrieben:
Also 255 in Big Endian? Wie rechnet man das um in BlitzMax?

Einfach den BigEndianStream benutzen.

Phlox hat Folgendes geschrieben:
Öhm..?

Du setzt ja deinen Pixel aus einzelnen Farbkanälen zu einem Integer (da BBP = 32) zusammen. Wenn du zum Beispiel deinen Pixel so zusammensetzt: BlitzMax: [AUSKLAPPEN]
Local RGB:Int = (Red Shl 16) | (Green Shl 8) | Blue

dann ist Red-shift logischerweise 16, Green-shift 8 und Blue-shift 0.

Ich würde diese Werte empfehlen, da man RGB-Pixel normalerweise so zusammensetzt (darum heisst es ja RGB und nicht etwa GRB), aber wenn du aus irgendeinem Grund die Reihenfolge ändern willst, musst du einfach die Shift-Werte auch anpassen.
Man is the best computer we can put aboard a spacecraft ... and the only one that can be mass produced with unskilled labor. -- Wernher von Braun
 

Phlox

BeitragDi, Jun 14, 2011 12:46
Antworten mit Zitat
Benutzer-Profile anzeigen
Ok, vielen Dank!

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group