Hi, everyone: I am very sorry to trouble you, but I hope you can help to solve a problem about function "gdk_draw_rgb_image". I want to use function "gdk_draw_rgb_image" to show all colors in rgb buffer to the screen when the screen would be refreshed. My problems is that screen can only show the colors only one time, and then the screen becomes white. After screen is refreshed, how can I keep the colors on screen until next time to be refreshed? Thank you very much! The following is the most important codes: static int gtk_lcd_open(conf_object_t *lcd_dev, lcd_surface_t* surface) { lcd_gtk_device* dev = lcd_dev->obj; lcd_touchscreen_t* lcd_ts = SKY_get_interface(lcd_dev, LCD_TS_INTF_NAME); SkyEyeLCD_GTK *lcd; guint32 *fbmem; char *title; GtkWidget *touch_screen; assert(dev != NULL); DBG("In %s, width=%d, height=%d, begin_addr=0x%x,end_addr=0x%x\n, ", __FUNCTION__, surface->width, surface->height, surface->lcd_addr_begin, surface->lcd_addr_end); if (dev == NULL || surface->width <= 0 || surface->height <= 0) return -1; if ((fbmem = (guint32*)get_dma_addr(surface->lcd_addr_begin)) == NULL) { fpri
ntf(stderr, "[GTK_LCD]: Can't find LCD DMA from address 0x%x\n", surface->lcd_addr_begin); return -1; } DBG("In %s, fb_mem=0x%x\n", __FUNCTION__, fbmem); if ((lcd = (SkyEyeLCD_GTK*)malloc(sizeof(SkyEyeLCD_GTK))) == NULL) return -1; memset(lcd, 0, sizeof(SkyEyeLCD_GTK)); lcd->width = surface->width; lcd->virtual_width = surface->width + surface->lcd_line_offset; lcd->height = surface->height; lcd->depth = surface->depth; lcd->update_rect.width = -1; lcd->update_rect.height = -1; lcd->update_all = TRUE; lcd->fbmem = fbmem; /* allocate a ping-pong buffer to reduce unnecessary lc
d fresh */ lcd->fbmem_cp = (void *)malloc(surface->lcd_addr_end - surface->lcd_addr_begin); /* shenoubang 2012-4-9 */ gdk_rgb_init(); gtk_widget_set_default_colormap (gdk_rgb_get_cmap()); gtk_widget_set_default_visual (gdk_rgb_get_visual()); if(dev->lcd_lookup_color != NULL) { lcd->rgbbuf = (guchar*)malloc(lcd->width * lcd->height * 4); } else switch (lcd->depth) { case 1: case 2: case 4: lcd->rgbbuf = (guchar*)malloc(lcd->virtual_width * lcd->height); break; case 12: case 16: lcd->rgbbuf = (guchar*)malloc(lcd->virtual_width * lcd->height * 3); break; case 8: case 24: case 32: lcd->rgbbuf = (guchar*)fbmem; break; default: break; } DBG("In %s, lcd->rgbbuf=0x%x\n", __FUNCTION__, lcd->rgbbuf); lcd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_signal_connect(GTK_OBJECT(lcd->window), "delete-event",
GTK_SIGNAL_FUNC(gtk_true), NULL); DBG("In %s, lcd->rgbbuf=0x%x\n", __FUNCTION__, lcd->rgbbuf); lcd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_signal_connect(GTK_OBJECT(lcd->window), "delete-event", GTK_SIGNAL_FUNC(gtk_true), NULL); if ((title = g_strdup_printf("%dx%dx%d SkyEye LCD & Touch Screen (GTK+)", lcd->width, lcd->height, lcd->depth)) != NULL) { gtk_window_set_title(GTK_WINDOW(lcd->window), title); g_free(title); } DBG("In %s, set title\n", __FUNCTION__); gtk_widget_set_usize(lcd->w
indow, lcd->width, lcd->height); gtk_widget_set_events(lcd->window, GDK_EXPOSURE_MASK); touch_screen = gtk_event_box_new(); /* shenobuang 2012-4-10 */ gtk_event_box_set_above_child (touch_screen, TRUE); gtk_event_box_set_visible_window (touch_screen, TRUE); DBG("In %s, set event\n", __FUNCTION__); if(lcd_ts){ skyeye_printf_in_color(GREEN, "In %s, Have touch screen register callback\n\n\n", __FUNCTION__); gtk_container_add(GTK_CONTAINER(lcd->window), touch_screen); gtk_widget_set_events(touch_screen, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK); &
nbsp; gtk_signal_connect(GTK_OBJECT(touch_screen), "button-press-event", GTK_SIGNAL_FUNC(callback_button_press), (gpointer)lcd_ts); gtk_signal_connect(GTK_OBJECT(touch_screen), "button-release-event", GTK_SIGNAL_FUNC(callback_button_release), (gpointer)lcd_ts); gtk_signal_connect(GTK_OBJECT(touch_screen), "motion-notify-event", GTK_SIGNAL_FUNC(callback_motion_notify), (gpointer)lcd_ts); gtk_widget_realize(touch_screen); gdk_window_set_cursor(touch_screen->window, gdk_cursor_new(GDK_HAND2)); } //zy 2004-4-02 Add Drawing area lcd->drawing = gtk_
drawing_area_new(); gtk_container_add(GTK_CONTAINER(touch_screen), lcd->drawing); gtk_signal_connect(GTK_OBJECT(lcd->drawing), "expose-event", GTK_SIGNAL_FUNC(callback_expose_event), dev); gtk_widget_show_all(lcd->window); DBG("In %s, show all\n", __FUNCTION__); if (dev->lcd_lookup_color == NULL){ } switch (lcd->depth) { case 1: lcd->colormap = gdk_rgb_cmap_new(colors1b, 2); break; case 2: break; case 4: &
nbsp; lcd->colormap = gdk_rgb_cmap_new(colors4b, 16); break; case 8: lcd->colormap = gdk_rgb_cmap_new(colors8b, 256); break; default: break; } DBG("In %s, add redraw event\n", __FUNCTION__); //lcd->timer = gtk_timeout_add(200, (GtkFunction)callback_redraw, lcd->window); dev->gtk_win = (void*)lcd; #ifndef MK_LCD int timer_id; create_thread_scheduler(10000, Periodic_sched, timer_update, dev->obj, &timer_id); #endif //gtk_
main_iteration_do(FALSE); return 0; } static gboolean callback_expose_event(GtkWidget *widget, GdkEventExpose *event, lcd_gtk_device* dev) { ....... <ignore some codes> wordnum = lcd->virtual_width * rect.height * lcd->depth / 32; switch (lcd->depth) { case 16: { int refresh = 0; for (i = lcd->virtual_width * rect.y / 2; i < wordnum / 2; i++) { /* shenoubang 2012-4-9 */ &n
bsp; fbdata = ((guint64*)lcd->fbmem + i); fbdata_cp = ((guint64*)lcd->fbmem_cp + i); if (*fbdata != *fbdata_cp) { refresh = 1; *fbdata_cp = *fbdata; *(lcd->rgbbuf + i * 12 + 0) = (guchar)((*fbdata_cp & 0x0000f800) >> 8);
*(lcd->rgbbuf + i * 12 + 1) = (guchar)((*fbdata_cp & 0x000007e0) >> 3); *(lcd->rgbbuf + i * 12 + 2) = (guchar)((*fbdata_cp & 0x0000001f) << 3); *(lcd->rgbbuf + i * 12 + 3) = (guchar)((*fbdata_cp & 0xf8000000) >> 24); &
nbsp; *(lcd->rgbbuf + i * 12 + 4) = (guchar)((*fbdata_cp & 0x07e00000) >> 19); *(lcd->rgbbuf + i * 12 + 5) = (guchar)((*fbdata_cp & 0x001f0000) >> 13); *(lcd->rgbbuf + i * 12 + 6) = (guchar)(((*fbdata_cp >> 32) & 0x0000f800) >> 8); *(lcd->rgbbuf + i *
12 + 7) = (guchar)(((*fbdata_cp >> 32) & 0x000007e0) >> 3); *(lcd->rgbbuf + i * 12 + 8) = (guchar)(((*fbdata_cp >> 32) & 0x0000001f) << 3); *(lcd->rgbbuf + i * 12 + 9) = (guchar)(((*fbdata_cp >> 32) & 0xf8000000) >> 24); *(lcd->rgbbuf + i *
12 + 10) = (guchar)(((*fbdata_cp >> 32) & 0x07e00000) >> 19); *(lcd->rgbbuf + i * 12 + 11) = (guchar)(((*fbdata_cp >> 32) & 0x001f0000) >> 13); } } if (refresh) { GDK_THREADS_ENTER
(); skyeye_printf_in_color(RED, "refresh: %d\n", refresh); gdk_draw_rgb_image(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], 0, rect.y, lcd->width, rect.height, GDK_RGB_DITHER_MAX, (guchar*)lcd->rgbbuf + rect.y * lcd->virtual_width * 3,
lcd->virtual_width * 3); GDK_THREADS_LEAVE(); } } break; ......... <ignore some codes> return TRUE; } |
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list