#include "wx/dcmemory.h"
#include "wx/app.h"
+#ifdef __WXGTK20__
+ // need this to get gdk_image_new_bitmap()
+ #define GDK_ENABLE_BROKEN
+#endif
+
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#if (GTK_MINOR_VERSION > 0)
-#include <gdk/gdkrgb.h>
-#endif
+#ifdef __WXGTK20__
+ #include <gdk/gdkimage.h>
+#else // GTK+ 1.2
+ #include <gdk/gdkrgb.h>
+#endif // GTK+ 2.0/1.2
extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
GdkGC *gc,
m_bitmap = (GdkBitmap*) NULL;
}
- wxImage image( bitmap );
+ wxImage image = bitmap.ConvertToImage();
if (!image.Ok()) return FALSE;
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
bool wxBitmap::CreateFromXpm( const char **bits )
{
+ UnRef();
+
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
GdkVisual *visual = wxTheApp->GetGdkVisual();
}
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
-
- M_BMPDATA->m_bpp = visual->depth; // ?
+
+ M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ?
return TRUE;
}
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
{
+ UnRef();
+
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
SetDepth( 1 );
-
+
GdkVisual *visual = wxTheApp->GetGdkVisual();
// Create picture image
int bpp = visual->depth;
SetDepth( bpp );
-
+
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp < 8) bpp = 8;
// We handle 8-bit bitmaps ourselves using the colour cube, 12-bit
// visuals are not supported by GDK so we do these ourselves, too.
// 15-bit and 16-bit should actually work and 24-bit certainly does.
+#ifdef __sgi
+ if (!image.HasMask() && (bpp > 16))
+#else
if (!image.HasMask() && (bpp > 12))
+#endif
{
static bool s_hasInitialized = FALSE;
if (bpp > 8)
{
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
- else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
+ else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RBG;
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
image.Create( GetWidth(), GetHeight() );
char unsigned *data = image.GetData();
-
+
if (!data)
{
gdk_image_destroy( gdk_image );
// Try to save the bitmap via wxImage handlers:
{
- wxImage image( *this );
+ wxImage image = ConvertToImage();
if (image.Ok()) return image.SaveFile( name, type );
}
{
wxImage image;
if (!image.LoadFile( name, type )) return FALSE;
- if (image.Ok()) *this = image.ConvertToBitmap();
+ if (image.Ok())
+ *this = wxBitmap(image);
else return FALSE;
}