fixed drawing on laptop

test16bit
Steffen Pohle 4 years ago
parent cd83c80237
commit 258494c571

@ -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_btnrefreshlist (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_video_btnrec (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_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 // thread handles

@ -26,6 +26,7 @@
<object class="GtkDrawingArea" id="video-da"> <object class="GtkDrawingArea" id="video-da">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<signal name="draw" handler="cb_videoda_draw" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="resize">False</property> <property name="resize">False</property>

@ -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) { void video_draw_image (VideoFrame *vf) {
int pix_w; 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); video_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, vf->w, vf->h);
pix_w = vf->w; pix_w = vf->w;
pix_h = vf->h; 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); video_convert(vf, video_pixbuf);
gdk_window_invalidate_rect(gtk_widget_get_window(video_da), NULL, true);
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);
*/
}; };
@ -328,9 +316,9 @@ gboolean cb_thread_video (gpointer data) {
gtk_widget_set_sensitive(btnstop, false); gtk_widget_set_sensitive(btnstop, false);
} }
else { else {
// printf ("%s:%d %s got video data\n", __FILE__, __LINE__, __FUNCTION__);
vf = videodev.FrameGet(); vf = videodev.FrameGet();
if (vf != NULL) video_draw_image(vf); if (vf != NULL) video_draw_image(vf);
else printf ("%s:%d %s could not get image data\n", __FILE__, __LINE__, __FUNCTION__);
videodev.FrameNext(); videodev.FrameNext();
} }

Loading…
Cancel
Save