From 258494c5719ebe8291b24be898d5eb115ce24318 Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Thu, 9 Sep 2021 15:06:54 +0200 Subject: [PATCH] fixed drawing on laptop --- gui.h | 1 + simpleskycam.ui | 1 + video.cc | 50 +++++++++++++++++++------------------------------ 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/gui.h b/gui.h index aed1b21..89c2626 100644 --- a/gui.h +++ b/gui.h @@ -39,6 +39,7 @@ G_MODULE_EXPORT gboolean cb_window_delete_event (GtkWidget *widget, G_MODULE_EXPORT void cb_video_btnrefreshlist (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_video_btnrec (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_video_btnstop (GtkWidget *widget, gpointer data); +G_MODULE_EXPORT void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data); // // thread handles diff --git a/simpleskycam.ui b/simpleskycam.ui index f3be78e..0a05317 100644 --- a/simpleskycam.ui +++ b/simpleskycam.ui @@ -26,6 +26,7 @@ True False + False diff --git a/video.cc b/video.cc index 66144b4..01089bd 100644 --- a/video.cc +++ b/video.cc @@ -189,6 +189,23 @@ void video_convert (VideoFrame *vf, GdkPixbuf *pixbuf) { +void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data) { + GdkRGBA color; + GtkStyleContext *context; + + context = gtk_widget_get_style_context (area); + + if (video_da == NULL) return; + + //cairo_move_to(cr, 30, 30); + //cairo_set_font_size(cr,15); + //cairo_show_text(cr, "hello world"); + + gdk_cairo_set_source_pixbuf(cr, video_pixbuf, 0, 0); + cairo_paint(cr); + cairo_fill (cr); +}; + void video_draw_image (VideoFrame *vf) { int pix_w; @@ -218,39 +235,10 @@ void video_draw_image (VideoFrame *vf) { video_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, vf->w, vf->h); pix_w = vf->w; pix_h = vf->h; - -// int channels = gdk_pixbuf_get_n_channels (video_pixbuf); -// int rowstride = gdk_pixbuf_get_rowstride (video_pixbuf); } video_convert(vf, video_pixbuf); - - GdkWindow* window = gtk_widget_get_window(video_da); - cairo_t *cr = gdk_cairo_create(window); - - gdk_cairo_set_source_pixbuf(cr, video_pixbuf, 0, 0); - cairo_paint(cr); - cairo_fill (cr); - -// cairo_move_to(cr, 30, 30); -// cairo_set_font_size(cr,15); -// cairo_show_text(cr, "hello world"); - - cairo_destroy (cr); - - /* - // - // "convert" the G*t*kWidget to G*d*kWindow (no, it's not a GtkWindow!) - GdkWindow* window = gtk_widget_get_window(video_da); - cairo_region_t * cairoRegion = cairo_region_create(); - GdkDrawingContext * drawingContext = gdk_window_begin_draw_frame (window,cairoRegion); - cairo_t * cr = gdk_drawing_context_get_cairo_context (drawingContext); - - - gdk_window_end_draw_frame(window,drawingContext); - cairo_region_destroy(cairoRegion); - - */ + gdk_window_invalidate_rect(gtk_widget_get_window(video_da), NULL, true); }; @@ -328,9 +316,9 @@ gboolean cb_thread_video (gpointer data) { gtk_widget_set_sensitive(btnstop, false); } else { - // printf ("%s:%d %s got video data\n", __FILE__, __LINE__, __FUNCTION__); vf = videodev.FrameGet(); if (vf != NULL) video_draw_image(vf); + else printf ("%s:%d %s could not get image data\n", __FILE__, __LINE__, __FUNCTION__); videodev.FrameNext(); }