[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dennou-ruby:001251] Gtk image graphics
堀之内です。
Ruby/GTK で画像ファイルでなくメモリー上のデータを描画したいので
すが、どうも良くわからないのでどなたか教えてください。
手元にあるデータは、2次元(256*256)の数値データで値は整数2バイト
分です。これを白黒かなにか適当なカラーマッピングで pixmap にして
表示したいというわけです。どうやら、gdk_pixmap_create_from_data
(Ruby/GtkではGdk::Pixmap.create_from_data)を使えば良さそうなの
ですが、使い方が良くわかりません。
Gdk (C API) のマニュアルでは
GdkPixmap*  gdk_pixmap_create_from_data     (GdkWindow *window,
                                              const gchar *data,
                                              gint width,
                                              gint height,
                                              gint depth,
                                              GdkColor *fg,
                                              GdkColor *bg);
Create a two-color pixmap from data in XBM data. 
         window : a GdkWindow, used to determine default values
                  for the new pixmap. Can be NULL, if the depth is given. 
           data : a pointer to the data. 
          width : the width of the new pixmap in pixels. 
         height : the height of the new pixmap in pixels. 
          depth : the depth (number of bits per pixel) of the new pixmap. 
             fg : the foreground color. 
             bg : the background color. 
          Returns : the GdkPixmap 
となってます。Ruby版の引数も同じです。fg や bg をどうすればいい
のかわからないし、window もよく分からない。あらかじめ width *
height 分の window を確保しろというのかしら。カラーマップはどこで
指定するのかもわからない(windowに込みなのだろうか?)。ちなみに
window は NULL に出来るそうですが、Ruby/Gtk ではそれをサボってま
す。nil なら NULL という風に出来るはずなのに。NULLの場合カラーマッ
プはどうなるのか? 
depthは2バイトのデータなら16ですね。わかるのはこれくらいです。
とほほ。