Lumiera  0.pre.03
»edit your freedom«
gdkdisplayer.cpp
Go to the documentation of this file.
1 /*
2  GgdkDisplayer - displaying video via GDK
3 
4  Copyright (C)
5  2000, Arne Schirmacher <arne@schirmacher.de>
6  2001-2007, Dan Dennedy <dan@dennedy.org>
7  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
8 
9   **Lumiera** is free software; you can redistribute it and/or modify it
10   under the terms of the GNU General Public License as published by the
11   Free Software Foundation; either version 2 of the License, or (at your
12   option) any later version. See the file COPYING for further details.
13 
14 * *****************************************************************/
15 
16 
24 #include "stage/gtk-base.hpp"
26 
27 #if false
28 #include <gdk/gdkx.h>
29 #endif
30 #include <iostream>
31 
32 using std::cerr;
33 using std::endl;
34 
35 
36 namespace stage {
37 namespace output {
38 
39  GdkDisplayer::GdkDisplayer (Gtk::Widget* drawing_area,
40  int width, int height)
41  : drawingArea( drawing_area )
42  {
43  REQUIRE (drawing_area != NULL);
44  REQUIRE (width > 0);
45  REQUIRE (height > 0);
46 
47  imageWidth = width,
48  imageHeight = height;
49  }
50 
51  bool
53  {
54  return false;
55  }
56 
57  void
58  GdkDisplayer::put (void* const image)
59  {
60  int video_x = 0,
61  video_y = 0,
62  video_width = 0,
63  video_height = 0;
64 
66  drawingArea->get_width(),
67  drawingArea->get_height(),
69  video_x, video_y, video_width, video_height);
70 
71  GdkWindow *window = drawingArea->get_window()->gobj();
72  REQUIRE (window != NULL);
73 
74  #if false
75  GdkGC *gc = gdk_gc_new( window );
76  REQUIRE(gc != NULL);
77 
78  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data( (const guchar*)image, GDK_COLORSPACE_RGB, FALSE, 8,
79  preferredWidth(), preferredHeight(), preferredWidth() * 3, NULL, NULL );
80  REQUIRE(pixbuf != NULL);
81 
82  GdkPixbuf *scaled_image = gdk_pixbuf_scale_simple( pixbuf, video_width, video_height, GDK_INTERP_NEAREST );
83  REQUIRE(scaled_image != NULL);
84 
85  gdk_draw_pixbuf( window, gc, scaled_image, 0, 0, video_x, video_y, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0 );
86 
87  g_object_unref( scaled_image );
88  g_object_unref( pixbuf );
89  g_object_unref( gc );
90  #endif
91  }
92 
93 
94 }} // namespace stage::output
static void calculateVideoLayout(int widget_width, int widget_height, int image_width, int image_height, int &video_x, int &video_y, int &video_width, int &video_height)
Calculates the coordinates for placing a video image inside a widget.
Definition: displayer.cpp:62
Gtk::Widget * drawingArea
The widget that video will be drawn into.
virtual int preferredHeight()
Expected height of input to put.
Definition: displayer.cpp:56
virtual int preferredWidth()
Expected width of input to put.
Definition: displayer.cpp:50
Display video via GDK.
bool usable()
Indicates if this object can be used to render images on the running system.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
GdkDisplayer(Gtk::Widget *drawing_area, int width, int height)
Constructor.
void put(void *const image)
Put an image of a given width and height with the expected input format (as indicated by the format m...
A set of basic GTK includes for the UI.