Commit 50a6ec06 authored by Cyril Deguet's avatar Cyril Deguet

* at last fixed transparency under linux !!

parent 8e5a7d79
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class * gtk2_bitmap.cpp: GTK2 implementation of the Bitmap class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_bitmap.cpp,v 1.15 2003/04/21 14:26:59 asmax Exp $ * $Id: gtk2_bitmap.cpp,v 1.16 2003/04/21 18:39:38 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor ) GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
: Bitmap( p_intf, FileName, AColor ) : Bitmap( p_intf, FileName, AColor )
{ {
AlphaColor = AColor;
// Load the bitmap image // Load the bitmap image
Bmp = gdk_pixbuf_new_from_file( FileName.c_str(), NULL ); Bmp = gdk_pixbuf_new_from_file( FileName.c_str(), NULL );
if( Bmp == NULL ) if( Bmp == NULL )
...@@ -57,11 +59,35 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor ) ...@@ -57,11 +59,35 @@ GTK2Bitmap::GTK2Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
Height = 0; Height = 0;
} }
else else
{ {
Bmp = gdk_pixbuf_add_alpha( Bmp, TRUE, AColor & 0xff, (AColor>>8) & 0xff,
(AColor>>16) & 0xff );
Width = gdk_pixbuf_get_width( Bmp ); Width = gdk_pixbuf_get_width( Bmp );
Height = gdk_pixbuf_get_height( Bmp ); Height = gdk_pixbuf_get_height( Bmp );
if( AColor != 0 )
{
// Change black pixels to another color to avoid transparency
int rowstride = gdk_pixbuf_get_rowstride( Bmp );
guchar *pixel = gdk_pixbuf_get_pixels( Bmp );
int pix_size = ( gdk_pixbuf_get_has_alpha( Bmp ) ? 4 : 3 );
for( int y = 0; y < Height; y++ )
{
for( int x = 0; x < Width; x++ )
{
guint32 r = pixel[0];
guint32 g = pixel[1]<<8;
guint32 b = pixel[2]<<16;
if( r+g+b == 0 )
{
pixel[2] = 10; // slight blue
}
pixel += pix_size;
}
}
}
Bmp = gdk_pixbuf_add_alpha( Bmp, TRUE, AColor & 0xff, (AColor>>8) & 0xff,
(AColor>>16) & 0xff );
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_font.cpp: GTK2 implementation of the Font class * gtk2_font.cpp: GTK2 implementation of the Font class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_font.cpp,v 1.11 2003/04/19 12:39:14 karibu Exp $ * $Id: gtk2_font.cpp,v 1.12 2003/04/21 18:39:38 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -67,13 +67,18 @@ GTK2Font::GTK2Font( intf_thread_t *_p_intf, string fontname, int size, ...@@ -67,13 +67,18 @@ GTK2Font::GTK2Font( intf_thread_t *_p_intf, string fontname, int size,
pango_font_description_set_weight( FontDesc, (PangoWeight)weight ); pango_font_description_set_weight( FontDesc, (PangoWeight)weight );
/* FIXME: underline parameter */
// Set attributes
//PangoFont* font = pango_context_load_font( Context, FontDesc );
//pango_context_set_font_description( Context, FontDesc ); //pango_context_set_font_description( Context, FontDesc );
pango_layout_set_font_description( Layout, FontDesc ); pango_layout_set_font_description( Layout, FontDesc );
// Set attributes
PangoAttrList *attrs = pango_attr_list_new();
/* FIXME: doesn't work */
if( underline )
{
pango_attr_list_insert( attrs,
pango_attr_underline_new( PANGO_UNDERLINE_SINGLE ) );
}
pango_layout_set_attributes( Layout, attrs );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
GTK2Font::~GTK2Font() GTK2Font::~GTK2Font()
...@@ -113,6 +118,9 @@ void GTK2Font::GenericPrint( Graphics *dest, string text, int x, int y, ...@@ -113,6 +118,9 @@ void GTK2Font::GenericPrint( Graphics *dest, string text, int x, int y,
// Set attributes // Set attributes
pango_layout_set_alignment( Layout, (PangoAlignment)align ); pango_layout_set_alignment( Layout, (PangoAlignment)align );
// Avoid transrency for black text
if( color == 0 ) color = 10;
gdk_rgb_gc_set_foreground( gc, color ); gdk_rgb_gc_set_foreground( gc, color );
// Render text on buffer // Render text on buffer
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk2_window.cpp: GTK2 implementation of the Window class * gtk2_window.cpp: GTK2 implementation of the Window class
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: gtk2_window.cpp,v 1.25 2003/04/21 14:26:59 asmax Exp $ * $Id: gtk2_window.cpp,v 1.26 2003/04/21 18:39:38 asmax Exp $
* *
* Authors: Cyril Deguet <asmax@videolan.org> * Authors: Cyril Deguet <asmax@videolan.org>
* *
...@@ -131,8 +131,11 @@ GTK2Window::~GTK2Window() ...@@ -131,8 +131,11 @@ GTK2Window::~GTK2Window()
DropTarget->Release(); DropTarget->Release();
// Uninitialize the OLE library // Uninitialize the OLE library
OleUninitialize(); OleUninitialize();
}*/
if( gWnd )
{
gdk_window_destroy( gWnd );
} }
*/
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void GTK2Window::OSShow( bool show ) void GTK2Window::OSShow( bool show )
...@@ -140,6 +143,7 @@ void GTK2Window::OSShow( bool show ) ...@@ -140,6 +143,7 @@ void GTK2Window::OSShow( bool show )
if( show ) if( show )
{ {
gdk_window_show( gWnd ); gdk_window_show( gWnd );
gdk_window_move( gWnd, Left, Top );
} }
else else
{ {
...@@ -289,24 +293,28 @@ void GTK2Window::RefreshFromImage( int x, int y, int w, int h ) ...@@ -289,24 +293,28 @@ void GTK2Window::RefreshFromImage( int x, int y, int w, int h )
GdkRegion *region = gdk_region_new(); GdkRegion *region = gdk_region_new();
for( int line = 0; line < Height; line++ ) for( int line = 0; line < Height; line++ )
{ {
int start = 0; int start = 0, end = 0;
while( gdk_image_get_pixel( image, start, line ) == 0 && start < Width-1) while( start < Width )
{
start++;
}
int end = Width - 1;
while( end >=0 && gdk_image_get_pixel( image, end, line ) == 0)
{ {
end--; while( start < Width && gdk_image_get_pixel( image, start, line ) == 0 )
{
start++;
}
end = start;
while( end < Width && gdk_image_get_pixel( image, end, line ) != 0)
{
end++;
}
GdkRectangle rect;
rect.x = start;
rect.y = line;
rect.width = end - start + 1;
rect.height = 1;
GdkRegion *rectReg = gdk_region_rectangle( &rect );
gdk_region_union( region, rectReg );
gdk_region_destroy( rectReg );
start = end + 1;
} }
GdkRectangle rect;
rect.x = start;
rect.y = line;
rect.width = end - start + 1;
rect.height = 1;
GdkRegion *rectReg = gdk_region_rectangle( &rect );
gdk_region_union( region, rectReg );
gdk_region_destroy( rectReg );
} }
gdk_window_shape_combine_region( gWnd, region, 0, 0 ); gdk_window_shape_combine_region( gWnd, region, 0, 0 );
gdk_region_destroy( region ); gdk_region_destroy( region );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* skin-main.cpp: skins plugin for VLC * skin-main.cpp: skins plugin for VLC
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: skin_main.cpp,v 1.15 2003/04/21 02:50:49 asmax Exp $ * $Id: skin_main.cpp,v 1.16 2003/04/21 18:39:39 asmax Exp $
* *
* Authors: Olivier Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr> * Emmanuel Puig <karibu@via.ecp.fr>
...@@ -105,6 +105,15 @@ static int Open ( vlc_object_t *p_this ) ...@@ -105,6 +105,15 @@ static int Open ( vlc_object_t *p_this )
p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf, p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
#if !defined WIN32
// Initialize GDK
int i_args = 1;
char *p_args[] = { "", NULL };
char **pp_args = p_args;
gdk_init( &i_args, &pp_args );
#endif
// Initialize conditions // Initialize conditions
vlc_mutex_init( p_intf, &p_intf->p_sys->init_lock); vlc_mutex_init( p_intf, &p_intf->p_sys->init_lock);
vlc_cond_init( p_intf, &p_intf->p_sys->init_cond); vlc_cond_init( p_intf, &p_intf->p_sys->init_cond);
...@@ -153,16 +162,6 @@ static void Close ( vlc_object_t *p_this ) ...@@ -153,16 +162,6 @@ static void Close ( vlc_object_t *p_this )
static void Run( intf_thread_t *p_intf ) static void Run( intf_thread_t *p_intf )
{ {
#if !defined WIN32
/* FIXME: should be elsewhere ? */
// Initialize GDK
int i_args = 1;
char *p_args[] = { "", NULL };
char **pp_args = p_args;
gdk_init( &i_args, &pp_args );
#endif
int a = OSAPI_GetTime(); int a = OSAPI_GetTime();
// Load a theme // Load a theme
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment