![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
RaspberryPIでNetBSDを動かしたときの色表示問題
![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
てことはやっぱりXserverは悪くなくて、単にicewmにRGBorder決め打ちにしてるっていうザル処理があるって考えるのが妥当だよな。
2013-10-17 12:33:06![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
X68kでicewm動かしても色狂うんちゃうかもしかして。15bit colorだけどRGBの順が違うから。GRBで5550。byteorderも違うから偶然起きないかもしれんが。
2013-10-17 12:43:24![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
pkgsrcにあるicewm (今1.2.35?)では、xpmの画像を表示するのに、読み込んだXImageから画像のデータバイトのみをchar 配列に取り出している。
2013-10-17 23:29:17![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
取り出す際には、ちゃんとXserverのDefaultVisualからr,g,b のmaskを参照して、charの1番めは赤、2番めは緑、3番目は青、という順にRGBそれぞれ分解して保管。このときはR->G->Bという順は固定。
2013-10-17 23:31:32![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
このXImageのデータ部分に、さっきのRGB単位で分解された配列を、なぜか「1バイトめを3バイトめに、2バイトめを2バイトめに、3バイトめを1バイトめに」なるように格納している。この順序や入れ替えパターンは固定。
2013-10-17 23:34:34![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
つまり取り出したR->G->Bの順で作られているバイト列を、今度はXImage->dataにB->G->Rの順で格納する。
2013-10-17 23:38:03![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
この値は、i386なんかのXserverでrgb maskが 0xff0000, 0xff00, 0xff な環境ではピッタシ。無問題。
2013-10-17 23:41:23![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
しかしながら、ここで使う新しいXImageはまだrgb maskが設定されておらず0のままのはず。が、しかし、maskが0の場合はDefault Visualからmaskを求めて突っ込むというコードがあるので、おそらくそこを通っている(未確認)
2013-10-17 23:42:16![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
つまり、VC4のようなrgb maskが 0xff,0xff00,0xff0000 な環境でこの処理を実行すると、RRGGBBのはずがBBGGRRとして扱われる。
2013-10-17 23:43:14![](https://tgfile.tg-static.com/static/web/img/placeholder.gif)
この処理は、こともあろうか、RGB maskが 0xff0000, 0xff00, 0xff 或いは 0xff00, 0xff00, 0xff0000 の時だけ行われる。
2013-10-17 23:44:36