[英]Incorrect color encoding in Remote Framebuffer server
我正在研究使用“ RAW”像素編碼的RFB服務器的簡單實現。 我正在使用TightVNC作為桌面客戶端。 我的代碼可以處理到客戶端能夠請求整個640x480像素的“桌面”的程度。 我的測試圖案可以正確繪制形狀,但是顏色不正確。
我正在嘗試使用每個像素8位:每個字節中編碼為RRRGGGBB
三個紅色,三個綠色和兩個藍色。
我的ServerInit數據包包含此像素編碼規范...
//all of these 13 fields are unsigned chars...
si.pf.bits_per_pixel = 8;
si.pf.depth = 8;
si.pf.big_endian_flag = 0;
si.pf.true_colour_flag = 1;
si.pf.red_max_hi = 0;
si.pf.red_max_lo = 7; // 3 bits
si.pf.green_max_hi = 0;
si.pf.green_max_lo = 7; // 3 bits
si.pf.blue_max_hi = 0;
si.pf.blue_max_lo = 3; // 2 bits
si.pf.red_shift = 5; // >>>>>RRR
si.pf.green_shift = 2; // >>RRRGGG
si.pf.blue_shift = 0; // RRRGGGBB
//remaining fields are omitted
因此定義了整個結構:
typedef struct
{
uchar bits_per_pixel;
uchar depth;
uchar big_endian_flag;
uchar true_colour_flag;
uchar red_max_hi;
uchar red_max_lo;
uchar green_max_hi;
uchar green_max_lo;
uchar blue_max_hi;
uchar blue_max_lo;
uchar red_shift;
uchar green_shift;
uchar blue_shift;
uchar padding0;
uchar padding1;
uchar padding2;
}tPixelFormat;
現在,如果我用0xe0
(二進制111 000 00
)填充桌面圖像,那么我希望將其解釋為純鮮紅色。 但是它顯示為淺藍色(好像8個單獨的位向后解釋了!)。 測試圖案的形狀正確,因為我在頂部角落繪制了一些白色像素(顯然,白色是二進制111 111 11
)。
我不明白這個。 我相信我遵循了RFB規范中描述的算法和編碼... http://vncdotool.readthedocs.org/en/latest/rfbproto.html#serverinit
我究竟做錯了什么?
Wireshark進行救援! 解決了。
事實證明,客戶SetPixelFormat
在發送一個我未曾見過的SetPixelFormat
請求,代碼忽略了它,並且顯然服務器被授權通過更改其輸出格式來滿足該請求。
解決方法是從一開始就通過硬編碼客戶端要求的值來簡單地向客戶端提供所需的內容。 此時客戶端不再發送該請求,因為它對服務器從一開始就拋出的內容感到滿意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.