gdkCursorNewFromPixmap示例错误

时间:2013-10-11 21:41:55

标签: r gtk gdk

来自gdkCursorNewFromPixmap的示例代码在Ubuntu上导致错误,R 2.14.1和RGtk2 2.20.25

代码:

library(RGtk2)

# This data is in X bitmap format, and can be created with the 'bitmap' utility in X11
cursor1_width <- 16
cursor1_height <- 16
cursor1_bits <- c(
  0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20,
  0x82, 0x41, 0x41, 0x82, 0x41, 0x82, 0x82, 0x41, 0x04, 0x20, 0x08, 0x10,
  0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01)
cursor1mask_bits <- c(
  0x80, 0x01, 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x8c, 0x31,
  0xc6, 0x63, 0x63, 0xc6, 0x63, 0xc6, 0xc6, 0x63, 0x8c, 0x31, 0x18, 0x18,
  0x30, 0x0c, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01)
 fg <- c(65535, 0, 0) # Red.
 bg <- c(0, 0, 65535) # Blue.
 source <- gdkPixmapNew(NULL, cursor1_width, cursor1_height, 8) 
 mask <- gdkPixmapNew(NULL, cursor1_width, cursor1_height, 8) 
 cursor <- gdkCursorNewFromPixmap(source, mask, fg, bg,0,0 )

错误:

Error in checkPtrType(source, "GdkPixmap") : 
  object of class GdkBitmap, RGtkObject isn't a GdkPixmap
Calls: gdkCursorNewFromPixmap -> checkPtrType

1 个答案:

答案 0 :(得分:0)

归结为GdkPixmap不等于GdkBitmap,使用gtk_pixmap_new代替gtk_bitmap_create_from_data(不推荐使用btw)(根据R namsing约定进行调整)< / p>