Module: VNCRec::RFB::EncRaw

Defined in:
lib/vncrec/rfb/encraw.rb

Class Method Summary collapse

Class Method Details

.read_rect(io, x, y, w, h, bitspp, fb, fbw, fbh) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vncrec/rfb/encraw.rb', line 4

def self.read_rect(io, x, y, w, h, bitspp, fb, fbw, fbh)
  bytespp = (bitspp.to_f / 8.0).to_i
  rectsize = w * h * bytespp
  data = io.read(rectsize)

  if (x + w) * bytespp > fbw
    if x * bytespp > fbw
      return
    else
      w = fbw / bytespp - x
    end
  end
  if (y + h) > fbh
    if y > fbh
      return
    else
      h = fbh - y
    end
  end

  row = 0
  while row < h
    topleft = fbw * (y + row) + x * bytespp
    fb[topleft ... topleft + w * bytespp] = data[row * w * bytespp ... (row + 1) * w * bytespp]
    row += 1
  end
end