Support variable bit depths. Fix color issues.

This commit is contained in:
Simo Kinnunen
2015-09-21 16:28:05 +09:00
parent 9d20484dcb
commit 977b8c198e
3 changed files with 41 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
var util = require('util')
var os = require('os')
var EventEmitter = require('eventemitter3').EventEmitter
var debug = require('debug')('vnc:connection')
@@ -26,7 +27,7 @@ function VncConnection(conn, options) {
this._serverPixelFormat = new PixelFormat({
bitsPerPixel: 24
, depth: 24
, bigEndianFlag: 0
, bigEndianFlag: os.endianness() == 'BE' ? 1 : 0
, trueColorFlag: 1
, redMax: 255
, greenMax: 255
@@ -35,7 +36,6 @@ function VncConnection(conn, options) {
, greenShift: 8
, blueShift: 0
})
this._requireServerPixelFormat = true
this._serverName = this.options.name
this._clientVersion = null
@@ -202,6 +202,7 @@ VncConnection.prototype._writeSecurityResult = function(result, reason) {
}
VncConnection.prototype._writeServerInit = function() {
debug('server pixel format', this._serverPixelFormat)
var chunk = new Buffer(2 + 2 + 16 + 4 + this._serverName.length)
chunk.writeUInt16BE(this._serverWidth, 0)
chunk.writeUInt16BE(this._serverHeight, 2)
@@ -318,12 +319,7 @@ VncConnection.prototype._read = function() {
})
// [16b, 19b) padding
debug('client pixel format', this._clientPixelFormat)
if (this._requireServerPixelFormat &&
this._clientPixelFormat.bitsPerPixel <
this._serverPixelFormat.bitsPerPixel) {
this.end()
return
}
this.emit('formatchange', this._clientPixelFormat)
this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE)
}
break