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) Lumiera.org
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  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of
12  the License, or (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 
23 * *****************************************************/
24 
25 
33 #include "stage/gtk-base.hpp"
35 
36 #if false
37 #include <gdk/gdkx.h>
38 #endif
39 #include <iostream>
40 
41 using std::cerr;
42 using std::endl;
43 
44 
45 namespace stage {
46 namespace output {
47 
48  GdkDisplayer::GdkDisplayer (Gtk::Widget *drawing_area,
49  int width, int height)
50  : drawingArea( drawing_area )
51  {
52  REQUIRE (drawing_area != NULL);
53  REQUIRE (width > 0);
54  REQUIRE (height > 0);
55 
56  imageWidth = width,
57  imageHeight = height;
58  }
59 
60  bool
62  {
63  return false;
64  }
65 
66  void
67  GdkDisplayer::put (void* const image)
68  {
69  int video_x = 0,
70  video_y = 0,
71  video_width = 0,
72  video_height = 0;
73 
75  drawingArea->get_width(),
76  drawingArea->get_height(),
78  video_x, video_y, video_width, video_height);
79 
80  GdkWindow *window = drawingArea->get_window()->gobj();
81  REQUIRE (window != NULL);
82 
83  #if false
84  GdkGC *gc = gdk_gc_new( window );
85  REQUIRE(gc != NULL);
86 
87  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data( (const guchar*)image, GDK_COLORSPACE_RGB, FALSE, 8,
88  preferredWidth(), preferredHeight(), preferredWidth() * 3, NULL, NULL );
89  REQUIRE(pixbuf != NULL);
90 
91  GdkPixbuf *scaled_image = gdk_pixbuf_scale_simple( pixbuf, video_width, video_height, GDK_INTERP_NEAREST );
92  REQUIRE(scaled_image != NULL);
93 
94  gdk_draw_pixbuf( window, gc, scaled_image, 0, 0, video_x, video_y, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0 );
95 
96  g_object_unref( scaled_image );
97  g_object_unref( pixbuf );
98  g_object_unref( gc );
99  #endif
100  }
101 
102 
103 }} // 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:71
Gtk::Widget * drawingArea
The widget that video will be drawn into.
virtual int preferredHeight()
Expected height of input to put.
Definition: displayer.cpp:65
virtual int preferredWidth()
Expected width of input to put.
Definition: displayer.cpp:59
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:46
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.