[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [dennou-ruby:001251] Gtk image graphics



��߷�Ǥ���


> �긵�ˤ���ǡ����ϡ�2����(256*256)�ο��ͥǡ������ͤ��������Х���
> ʬ�Ǥ��������������ʤˤ�Ŭ���ʥ��顼�ޥåԥ󥰤� pixmap �ˤ���
> ɽ���������Ȥ����櫓�Ǥ����ɤ���顢gdk_pixmap_create_from_data
> (Ruby/Gtk�Ǥ�Gdk::Pixmap.create_from_data�ˤ�Ȥ����ɤ������ʤ�
> �Ǥ������Ȥ������ɤ��狼��ޤ���

Ruby-Gnome �Υ᡼��󥰥ꥹ�Ȥ�ʹ���Ƥߤޤ�����

gdk_pixmap_create_from_data�Ǥ���
1�ԥ���������1�ӥåȤΥǡ�����������ߤ����Ǥ���<- XMB�ǡ���
�Ǥ���Τ�Pixmap�Ǥ���2���ΤߤǤ���

depth : the depth (number of bits per pixel) of the new pixmap. 
�Ϥ�ȤΥǡ����Ȥϴط��ʤ��ߤ����Ǥ���
�����Pixmap��depth�Ǥ���
ɽ�����뤿��ˤ�window��Ʊ���ͤˤ���ɬ�פ�����ߤ����Ǥ���(24 or 32)

fg,bg�ϥǡ�����1��fg�ο���0��bg�ο��ˤʤ�ޤ���


require "gtk"

data = [
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xf0, 0x3f, 0x00, 0xe0, 0x78, 0x00, 0xe0, 0x70, 0x00, 0xe0, 0x70, 0x00,
   0xe0, 0x38, 0x00, 0xe0, 0x1f, 0x00, 0xe0, 0x1d, 0x00, 0xe0, 0x38, 0x00,
   0xe0, 0x78, 0x00, 0xe0, 0xf0, 0x00, 0xf0, 0xf3, 0x01, 0xf0, 0xe3, 0x01,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00].pack("c*")

window = Gtk::Window.new
window.set_usize(28,24)
window.set_app_paintable(true)
window.realize

red   = Gdk::Color.new(65535, 0, 0)
green = Gdk::Color.new(0, 65535, 0)
colormap = Gdk::Colormap.get_system
colormap.alloc_color(red, false, true)
colormap.alloc_color(green, false, true)

pixmap = Gdk::Pixmap.create_from_data(window.window, data, 24, 20, 24, red, green)
gc = Gdk::GC.new(window.window)

window.signal_connect("expose_event"){|widget, evt|
  widget.window.draw_pixmap(gc, pixmap, 0, 0, 2, 2, -1, -1)
}

window.show_all
Gtk.main


----------
Seiya Nishizawa
seiya@xxxxxx