Some additions to the 12-bit patch.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13524 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-01-12 12:21:57 +00:00
parent 8ab696e0a9
commit 005f5d1878
7 changed files with 133 additions and 124 deletions

View File

@@ -1880,6 +1880,7 @@ typedef struct _GdkColor GdkColor;
typedef struct _GdkColormap GdkColormap; typedef struct _GdkColormap GdkColormap;
typedef struct _GdkFont GdkFont; typedef struct _GdkFont GdkFont;
typedef struct _GdkGC GdkGC; typedef struct _GdkGC GdkGC;
typedef struct _GdkVisual GdkVisual;
#ifdef __WXGTK20__ #ifdef __WXGTK20__
typedef struct _GdkDrawable GdkWindow; typedef struct _GdkDrawable GdkWindow;
typedef struct _GdkDrawable GdkBitmap; typedef struct _GdkDrawable GdkBitmap;

View File

@@ -76,9 +76,12 @@ public:
#endif #endif
unsigned char *m_colorCube; unsigned char *m_colorCube;
// used by the the wxGLApp and wxGLCanvas class for GL-based X visual // Used by the the wxGLApp and wxGLCanvas class for GL-based X visual
// selection; this is actually an XVisualInfo* // selection; this is actually an XVisualInfo*
void *m_glVisualInfo; void *m_glVisualInfo;
// This returns the current visual: either that used by wxRootWindow
// or the XVisualInfo* for SGI.
GdkVisual *GetGdkVisual();
private: private:
// true if we're inside an assert modal dialog // true if we're inside an assert modal dialog

View File

@@ -76,9 +76,12 @@ public:
#endif #endif
unsigned char *m_colorCube; unsigned char *m_colorCube;
// used by the the wxGLApp and wxGLCanvas class for GL-based X visual // Used by the the wxGLApp and wxGLCanvas class for GL-based X visual
// selection; this is actually an XVisualInfo* // selection; this is actually an XVisualInfo*
void *m_glVisualInfo; void *m_glVisualInfo;
// This returns the current visual: either that used by wxRootWindow
// or the XVisualInfo* for SGI.
GdkVisual *GetGdkVisual();
private: private:
// true if we're inside an assert modal dialog // true if we're inside an assert modal dialog

View File

@@ -318,6 +318,20 @@ void wxapp_uninstall_thread_wakeup()
#endif // wxUSE_THREADS #endif // wxUSE_THREADS
//-----------------------------------------------------------------------------
// Access to the root window global
//-----------------------------------------------------------------------------
GtkWidget* wxGetRootWindow()
{
if (gs_RootWindow == NULL)
{
gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_widget_realize( gs_RootWindow );
}
return gs_RootWindow;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxApp // wxApp
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -369,9 +383,10 @@ bool wxApp::OnInitGui()
// if this is a wxGLApp (derived from wxApp), and we've already // if this is a wxGLApp (derived from wxApp), and we've already
// chosen a specific visual, then derive the GdkVisual from that // chosen a specific visual, then derive the GdkVisual from that
if (m_glVisualInfo != NULL) { if (m_glVisualInfo != NULL)
{
#ifdef __WXGTK20__ #ifdef __WXGTK20__
/* seems gtk_widget_set_default_visual no longer exists? */ // seems gtk_widget_set_default_visual no longer exists?
GdkVisual* vis = gtk_widget_get_default_visual(); GdkVisual* vis = gtk_widget_get_default_visual();
#else #else
GdkVisual* vis = gdkx_visual_get( GdkVisual* vis = gdkx_visual_get(
@@ -385,12 +400,11 @@ bool wxApp::OnInitGui()
visual = vis; visual = vis;
} }
/* on some machines, the default visual is just 256 colours, so // On some machines, the default visual is just 256 colours, so
we make sure we get the best. this can sometimes be wasteful, // we make sure we get the best. This can sometimes be wasteful.
of course, but what do these guys pay $30.000 for? */
else if ((gdk_visual_get_best() != gdk_visual_get_system()) && else
(m_useBestVisual)) if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual))
{ {
#ifdef __WXGTK20__ #ifdef __WXGTK20__
/* seems gtk_widget_set_default_visual no longer exists? */ /* seems gtk_widget_set_default_visual no longer exists? */
@@ -406,10 +420,10 @@ bool wxApp::OnInitGui()
visual = vis; visual = vis;
} }
/* Nothing to do for 15, 16, 24, 32 bit displays */ // Nothing to do for 15, 16, 24, 32 bit displays
if (visual->depth > 8) return TRUE; if (visual->depth > 8) return TRUE;
/* initialize color cube for 8-bit color reduction dithering */ // initialize color cube for 8-bit color reduction dithering
GdkColormap *cmap = gtk_widget_get_default_colormap(); GdkColormap *cmap = gtk_widget_get_default_colormap();
@@ -446,16 +460,11 @@ bool wxApp::OnInitGui()
} }
else else
{ {
#if (GTK_MINOR_VERSION > 0) // assume 8-bit true or static colors. this really exists
/* assume 8-bit true or static colors. this really
exists. */
GdkVisual* vis = gdk_colormap_get_visual( cmap ); GdkVisual* vis = gdk_colormap_get_visual( cmap );
index = (r >> (5 - vis->red_prec)) << vis->red_shift; index = (r >> (5 - vis->red_prec)) << vis->red_shift;
index |= (g >> (5 - vis->green_prec)) << vis->green_shift; index |= (g >> (5 - vis->green_prec)) << vis->green_shift;
index |= (b >> (5 - vis->blue_prec)) << vis->blue_shift; index |= (b >> (5 - vis->blue_prec)) << vis->blue_shift;
#else
wxFAIL_MSG( wxT("Unsupported graphics hardware") );
#endif
} }
m_colorCube[ (r*1024) + (g*32) + b ] = index; m_colorCube[ (r*1024) + (g*32) + b ] = index;
} }
@@ -465,6 +474,20 @@ bool wxApp::OnInitGui()
return TRUE; return TRUE;
} }
GdkVisual *wxApp::GetGdkVisual()
{
GdkVisual *visual = NULL;
if (m_glVisualInfo)
visual = gdkx_visual_get( ((XVisualInfo *) wxTheApp->m_glVisualInfo)->visualid );
else
visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
return visual;
}
bool wxApp::ProcessIdle() bool wxApp::ProcessIdle()
{ {
wxIdleEvent event; wxIdleEvent event;
@@ -669,19 +692,6 @@ void wxApp::CleanUp()
#endif // wxUSE_LOG #endif // wxUSE_LOG
} }
//-----------------------------------------------------------------------------
// Access to the root window global
//-----------------------------------------------------------------------------
GtkWidget* wxGetRootWindow()
{
if (gs_RootWindow == NULL) {
gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_widget_realize( gs_RootWindow );
}
return gs_RootWindow;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxEntry // wxEntry
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -690,7 +700,7 @@ GtkWidget* wxGetRootWindow()
int wxEntryStart( int& argc, char *argv[] ) int wxEntryStart( int& argc, char *argv[] )
{ {
#if wxUSE_THREADS #if wxUSE_THREADS
/* GTK 1.2 up to version 1.2.3 has broken threads */ // GTK 1.2 up to version 1.2.3 has broken threads
if ((gtk_major_version == 1) && if ((gtk_major_version == 1) &&
(gtk_minor_version == 2) && (gtk_minor_version == 2) &&
(gtk_micro_version < 4)) (gtk_micro_version < 4))
@@ -768,7 +778,6 @@ void wxEntryCleanup()
} }
int wxEntry( int argc, char *argv[] ) int wxEntry( int argc, char *argv[] )
{ {
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT

View File

@@ -111,8 +111,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
unsigned char green = colour.Green(); unsigned char green = colour.Green();
unsigned char blue = colour.Blue(); unsigned char blue = colour.Blue();
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
@@ -121,12 +120,18 @@ bool wxMask::Create( const wxBitmap& bitmap,
red = red & 0xf8; red = red & 0xf8;
green = green & 0xf8; green = green & 0xf8;
blue = blue & 0xf8; blue = blue & 0xf8;
} } else
if (bpp == 16) if (bpp == 16)
{ {
red = red & 0xf8; red = red & 0xf8;
green = green & 0xfc; green = green & 0xfc;
blue = blue & 0xf8; blue = blue & 0xf8;
} else
if (bpp == 12)
{
red = red & 0xf0;
green = green & 0xf0;
blue = blue & 0xf0;
} }
color.red = 0; color.red = 0;
@@ -268,8 +273,7 @@ bool wxBitmap::Create( int width, int height, int depth )
wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") ) wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") )
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
if (depth == -1) depth = visual->depth; if (depth == -1) depth = visual->depth;
@@ -298,8 +302,7 @@ bool wxBitmap::CreateFromXpm( const char **bits )
{ {
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ) wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
@@ -344,8 +347,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetDepth( 1 ); SetDepth( 1 );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
// Create picture image // Create picture image
@@ -439,17 +441,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) ); SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
// Retrieve depth, using XVisualInfo from app, if set GdkVisual *visual = wxTheApp->GetGdkVisual();
GdkVisual *visual;
if (wxTheApp->m_glVisualInfo)
{
visual = gdkx_visual_get( ((XVisualInfo *) wxTheApp->m_glVisualInfo)->visualid );
}
else
{
visual = gdk_window_get_visual( wxGetRootWindow()->window );
}
wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
@@ -613,12 +605,12 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
guint32 pixel = 0; guint32 pixel = 0;
switch (b_o) switch (b_o)
{ {
case RGB: pixel = ((r & 0xf8) << 7) | ((g & 0xfc) << 2) | ((b & 0xf8) >> 3); break; case RGB: pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); break;
case RBG: pixel = ((r & 0xf8) << 7) | ((b & 0xfc) << 2) | ((g & 0xf8) >> 3); break; case RBG: pixel = ((r & 0xf8) << 8) | ((b & 0xfc) << 3) | ((g & 0xf8) >> 3); break;
case GRB: pixel = ((g & 0xf8) << 7) | ((r & 0xfc) << 2) | ((b & 0xf8) >> 3); break; case GRB: pixel = ((g & 0xf8) << 8) | ((r & 0xfc) << 3) | ((b & 0xf8) >> 3); break;
case GBR: pixel = ((g & 0xf8) << 7) | ((b & 0xfc) << 2) | ((r & 0xf8) >> 3); break; case GBR: pixel = ((g & 0xf8) << 8) | ((b & 0xfc) << 3) | ((r & 0xf8) >> 3); break;
case BRG: pixel = ((b & 0xf8) << 7) | ((r & 0xfc) << 2) | ((g & 0xf8) >> 3); break; case BRG: pixel = ((b & 0xf8) << 8) | ((r & 0xfc) << 3) | ((g & 0xf8) >> 3); break;
case BGR: pixel = ((b & 0xf8) << 7) | ((g & 0xfc) << 2) | ((r & 0xf8) >> 3); break; case BGR: pixel = ((b & 0xf8) << 8) | ((g & 0xfc) << 3) | ((r & 0xf8) >> 3); break;
} }
gdk_image_put_pixel( data_image, x, y, pixel ); gdk_image_put_pixel( data_image, x, y, pixel );
break; break;
@@ -725,8 +717,9 @@ wxImage wxBitmap::ConvertToImage() const
if (GetPixmap()) if (GetPixmap())
{ {
GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); GdkVisual *visual = gdk_window_get_visual( GetPixmap() );
if (visual == NULL)
visual = wxTheApp->GetGdkVisual();
if (visual == NULL) visual = gdk_window_get_visual( wxGetRootWindow()->window );
bpp = visual->depth; bpp = visual->depth;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec; if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift; red_shift_right = visual->red_shift;
@@ -956,8 +949,7 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
if (!wxFileExists(name)) return FALSE; if (!wxFileExists(name)) return FALSE;
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
if (type == wxBITMAP_TYPE_XPM) if (type == wxBITMAP_TYPE_XPM)
{ {

View File

@@ -318,6 +318,20 @@ void wxapp_uninstall_thread_wakeup()
#endif // wxUSE_THREADS #endif // wxUSE_THREADS
//-----------------------------------------------------------------------------
// Access to the root window global
//-----------------------------------------------------------------------------
GtkWidget* wxGetRootWindow()
{
if (gs_RootWindow == NULL)
{
gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_widget_realize( gs_RootWindow );
}
return gs_RootWindow;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxApp // wxApp
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -369,9 +383,10 @@ bool wxApp::OnInitGui()
// if this is a wxGLApp (derived from wxApp), and we've already // if this is a wxGLApp (derived from wxApp), and we've already
// chosen a specific visual, then derive the GdkVisual from that // chosen a specific visual, then derive the GdkVisual from that
if (m_glVisualInfo != NULL) { if (m_glVisualInfo != NULL)
{
#ifdef __WXGTK20__ #ifdef __WXGTK20__
/* seems gtk_widget_set_default_visual no longer exists? */ // seems gtk_widget_set_default_visual no longer exists?
GdkVisual* vis = gtk_widget_get_default_visual(); GdkVisual* vis = gtk_widget_get_default_visual();
#else #else
GdkVisual* vis = gdkx_visual_get( GdkVisual* vis = gdkx_visual_get(
@@ -385,12 +400,11 @@ bool wxApp::OnInitGui()
visual = vis; visual = vis;
} }
/* on some machines, the default visual is just 256 colours, so // On some machines, the default visual is just 256 colours, so
we make sure we get the best. this can sometimes be wasteful, // we make sure we get the best. This can sometimes be wasteful.
of course, but what do these guys pay $30.000 for? */
else if ((gdk_visual_get_best() != gdk_visual_get_system()) && else
(m_useBestVisual)) if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual))
{ {
#ifdef __WXGTK20__ #ifdef __WXGTK20__
/* seems gtk_widget_set_default_visual no longer exists? */ /* seems gtk_widget_set_default_visual no longer exists? */
@@ -406,10 +420,10 @@ bool wxApp::OnInitGui()
visual = vis; visual = vis;
} }
/* Nothing to do for 15, 16, 24, 32 bit displays */ // Nothing to do for 15, 16, 24, 32 bit displays
if (visual->depth > 8) return TRUE; if (visual->depth > 8) return TRUE;
/* initialize color cube for 8-bit color reduction dithering */ // initialize color cube for 8-bit color reduction dithering
GdkColormap *cmap = gtk_widget_get_default_colormap(); GdkColormap *cmap = gtk_widget_get_default_colormap();
@@ -446,16 +460,11 @@ bool wxApp::OnInitGui()
} }
else else
{ {
#if (GTK_MINOR_VERSION > 0) // assume 8-bit true or static colors. this really exists
/* assume 8-bit true or static colors. this really
exists. */
GdkVisual* vis = gdk_colormap_get_visual( cmap ); GdkVisual* vis = gdk_colormap_get_visual( cmap );
index = (r >> (5 - vis->red_prec)) << vis->red_shift; index = (r >> (5 - vis->red_prec)) << vis->red_shift;
index |= (g >> (5 - vis->green_prec)) << vis->green_shift; index |= (g >> (5 - vis->green_prec)) << vis->green_shift;
index |= (b >> (5 - vis->blue_prec)) << vis->blue_shift; index |= (b >> (5 - vis->blue_prec)) << vis->blue_shift;
#else
wxFAIL_MSG( wxT("Unsupported graphics hardware") );
#endif
} }
m_colorCube[ (r*1024) + (g*32) + b ] = index; m_colorCube[ (r*1024) + (g*32) + b ] = index;
} }
@@ -465,6 +474,20 @@ bool wxApp::OnInitGui()
return TRUE; return TRUE;
} }
GdkVisual *wxApp::GetGdkVisual()
{
GdkVisual *visual = NULL;
if (m_glVisualInfo)
visual = gdkx_visual_get( ((XVisualInfo *) wxTheApp->m_glVisualInfo)->visualid );
else
visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
return visual;
}
bool wxApp::ProcessIdle() bool wxApp::ProcessIdle()
{ {
wxIdleEvent event; wxIdleEvent event;
@@ -669,19 +692,6 @@ void wxApp::CleanUp()
#endif // wxUSE_LOG #endif // wxUSE_LOG
} }
//-----------------------------------------------------------------------------
// Access to the root window global
//-----------------------------------------------------------------------------
GtkWidget* wxGetRootWindow()
{
if (gs_RootWindow == NULL) {
gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_widget_realize( gs_RootWindow );
}
return gs_RootWindow;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxEntry // wxEntry
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -690,7 +700,7 @@ GtkWidget* wxGetRootWindow()
int wxEntryStart( int& argc, char *argv[] ) int wxEntryStart( int& argc, char *argv[] )
{ {
#if wxUSE_THREADS #if wxUSE_THREADS
/* GTK 1.2 up to version 1.2.3 has broken threads */ // GTK 1.2 up to version 1.2.3 has broken threads
if ((gtk_major_version == 1) && if ((gtk_major_version == 1) &&
(gtk_minor_version == 2) && (gtk_minor_version == 2) &&
(gtk_micro_version < 4)) (gtk_micro_version < 4))
@@ -768,7 +778,6 @@ void wxEntryCleanup()
} }
int wxEntry( int argc, char *argv[] ) int wxEntry( int argc, char *argv[] )
{ {
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT

View File

@@ -111,8 +111,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
unsigned char green = colour.Green(); unsigned char green = colour.Green();
unsigned char blue = colour.Blue(); unsigned char blue = colour.Blue();
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
@@ -121,12 +120,18 @@ bool wxMask::Create( const wxBitmap& bitmap,
red = red & 0xf8; red = red & 0xf8;
green = green & 0xf8; green = green & 0xf8;
blue = blue & 0xf8; blue = blue & 0xf8;
} } else
if (bpp == 16) if (bpp == 16)
{ {
red = red & 0xf8; red = red & 0xf8;
green = green & 0xfc; green = green & 0xfc;
blue = blue & 0xf8; blue = blue & 0xf8;
} else
if (bpp == 12)
{
red = red & 0xf0;
green = green & 0xf0;
blue = blue & 0xf0;
} }
color.red = 0; color.red = 0;
@@ -268,8 +273,7 @@ bool wxBitmap::Create( int width, int height, int depth )
wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") ) wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") )
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
if (depth == -1) depth = visual->depth; if (depth == -1) depth = visual->depth;
@@ -298,8 +302,7 @@ bool wxBitmap::CreateFromXpm( const char **bits )
{ {
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ) wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
@@ -344,8 +347,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetDepth( 1 ); SetDepth( 1 );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
// Create picture image // Create picture image
@@ -439,17 +441,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) ); SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
// Retrieve depth, using XVisualInfo from app, if set GdkVisual *visual = wxTheApp->GetGdkVisual();
GdkVisual *visual;
if (wxTheApp->m_glVisualInfo)
{
visual = gdkx_visual_get( ((XVisualInfo *) wxTheApp->m_glVisualInfo)->visualid );
}
else
{
visual = gdk_window_get_visual( wxGetRootWindow()->window );
}
wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
@@ -613,12 +605,12 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
guint32 pixel = 0; guint32 pixel = 0;
switch (b_o) switch (b_o)
{ {
case RGB: pixel = ((r & 0xf8) << 7) | ((g & 0xfc) << 2) | ((b & 0xf8) >> 3); break; case RGB: pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); break;
case RBG: pixel = ((r & 0xf8) << 7) | ((b & 0xfc) << 2) | ((g & 0xf8) >> 3); break; case RBG: pixel = ((r & 0xf8) << 8) | ((b & 0xfc) << 3) | ((g & 0xf8) >> 3); break;
case GRB: pixel = ((g & 0xf8) << 7) | ((r & 0xfc) << 2) | ((b & 0xf8) >> 3); break; case GRB: pixel = ((g & 0xf8) << 8) | ((r & 0xfc) << 3) | ((b & 0xf8) >> 3); break;
case GBR: pixel = ((g & 0xf8) << 7) | ((b & 0xfc) << 2) | ((r & 0xf8) >> 3); break; case GBR: pixel = ((g & 0xf8) << 8) | ((b & 0xfc) << 3) | ((r & 0xf8) >> 3); break;
case BRG: pixel = ((b & 0xf8) << 7) | ((r & 0xfc) << 2) | ((g & 0xf8) >> 3); break; case BRG: pixel = ((b & 0xf8) << 8) | ((r & 0xfc) << 3) | ((g & 0xf8) >> 3); break;
case BGR: pixel = ((b & 0xf8) << 7) | ((g & 0xfc) << 2) | ((r & 0xf8) >> 3); break; case BGR: pixel = ((b & 0xf8) << 8) | ((g & 0xfc) << 3) | ((r & 0xf8) >> 3); break;
} }
gdk_image_put_pixel( data_image, x, y, pixel ); gdk_image_put_pixel( data_image, x, y, pixel );
break; break;
@@ -725,8 +717,9 @@ wxImage wxBitmap::ConvertToImage() const
if (GetPixmap()) if (GetPixmap())
{ {
GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); GdkVisual *visual = gdk_window_get_visual( GetPixmap() );
if (visual == NULL)
visual = wxTheApp->GetGdkVisual();
if (visual == NULL) visual = gdk_window_get_visual( wxGetRootWindow()->window );
bpp = visual->depth; bpp = visual->depth;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec; if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift; red_shift_right = visual->red_shift;
@@ -956,8 +949,7 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
if (!wxFileExists(name)) return FALSE; if (!wxFileExists(name)) return FALSE;
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window ); GdkVisual *visual = wxTheApp->GetGdkVisual();
wxASSERT( visual );
if (type == wxBITMAP_TYPE_XPM) if (type == wxBITMAP_TYPE_XPM)
{ {