2008-05-12 14:02:14 +02:00
/*
2015-01-07 00:53:03 +01:00
GgdkDisplayer - displaying video via GDK
2010-12-17 23:28:49 +01:00
2008-05-12 14:02:14 +02:00
Copyright ( C ) Lumiera . org
2000 , Arne Schirmacher < arne @ schirmacher . de >
2001 - 2007 , Dan Dennedy < dan @ dennedy . org >
2008 , Joel Holdsworth < joel @ airwebreathe . org . uk >
2010-12-17 23:28:49 +01:00
2008-05-12 14:02:14 +02:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
published by the Free Software Foundation ; either version 2 of
the License , or ( at your option ) any later version .
2008-05-12 14:02:14 +02:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-12-17 23:28:49 +01:00
2008-05-12 14:02:14 +02:00
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
2010-12-17 23:28:49 +01:00
2008-05-12 14:02:14 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2015-01-07 00:53:03 +01:00
2016-11-03 18:22:31 +01:00
/** @file gdkdisplayer.cpp
2016-11-06 14:19:14 +01:00
* * Dysfunctional implementation code , formerly used to
* * create a video display based on GDK
* * @ deprecated obsolete since GTK - 3
2016-11-03 18:20:10 +01:00
*/
2010-12-27 05:50:40 +01:00
# include "gui/gtk-lumiera.hpp"
2014-08-17 07:02:48 +02:00
# include "gui/output/gdkdisplayer.hpp"
2008-05-12 14:02:14 +02:00
2014-10-05 09:32:06 +02:00
# if false ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
2008-05-12 14:02:14 +02:00
# include <gdk/gdkx.h>
2014-10-05 09:32:06 +02:00
# endif ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
2008-05-12 14:02:14 +02:00
# include <iostream>
2014-08-17 07:02:48 +02:00
2008-05-12 14:02:14 +02:00
using std : : cerr ;
using std : : endl ;
namespace gui {
namespace output {
2008-12-30 14:06:08 +01:00
2015-01-07 00:53:03 +01:00
GdkDisplayer : : GdkDisplayer ( Gtk : : Widget * drawing_area ,
int width , int height )
: drawingArea ( drawing_area )
{
REQUIRE ( drawing_area ! = NULL ) ;
REQUIRE ( width > 0 ) ;
REQUIRE ( height > 0 ) ;
imageWidth = width ,
imageHeight = height ;
}
bool
GdkDisplayer : : usable ( )
{
return false ; /////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
}
void
GdkDisplayer : : put ( void * const image )
{
int video_x = 0 ,
video_y = 0 ,
video_width = 0 ,
video_height = 0 ;
2008-12-30 14:06:08 +01:00
2015-01-07 00:53:03 +01:00
calculateVideoLayout (
drawingArea - > get_width ( ) ,
drawingArea - > get_height ( ) ,
preferredWidth ( ) , preferredHeight ( ) ,
video_x , video_y , video_width , video_height ) ;
2008-12-30 14:06:08 +01:00
2015-01-07 00:53:03 +01:00
GdkWindow * window = drawingArea - > get_window ( ) - > gobj ( ) ;
REQUIRE ( window ! = NULL ) ;
# if false ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
GdkGC * gc = gdk_gc_new ( window ) ;
REQUIRE ( gc ! = NULL ) ;
GdkPixbuf * pixbuf = gdk_pixbuf_new_from_data ( ( const guchar * ) image , GDK_COLORSPACE_RGB , FALSE , 8 ,
preferredWidth ( ) , preferredHeight ( ) , preferredWidth ( ) * 3 , NULL , NULL ) ;
REQUIRE ( pixbuf ! = NULL ) ;
GdkPixbuf * scaled_image = gdk_pixbuf_scale_simple ( pixbuf , video_width , video_height , GDK_INTERP_NEAREST ) ;
REQUIRE ( scaled_image ! = NULL ) ;
2008-06-07 14:53:17 +02:00
2015-01-07 00:53:03 +01:00
gdk_draw_pixbuf ( window , gc , scaled_image , 0 , 0 , video_x , video_y , - 1 , - 1 , GDK_RGB_DITHER_NORMAL , 0 , 0 ) ;
g_object_unref ( scaled_image ) ;
g_object_unref ( pixbuf ) ;
g_object_unref ( gc ) ;
# endif ///////////////////////////////////////////////////////////////////////////////////////////////////TICKET #950 : new solution for video display
}
2008-12-30 14:06:08 +01:00
2015-01-07 00:53:03 +01:00
} } // namespace gui::output