]> git.saurik.com Git - wxWidgets.git/commitdiff
wxImage now uses GTK 1.2's fast rendering code if possible
authorRobert Roebling <robert@roebling.de>
Fri, 16 Apr 1999 09:52:32 +0000 (09:52 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 16 Apr 1999 09:52:32 +0000 (09:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2190 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/controls/controls.cpp
samples/image/image.cpp
src/common/image.cpp

index 9b02248738d2dda22d949e8bb200e7bef68804c4..ed994f58f55b38d240327b7eda330180dc1e470d 100644 (file)
@@ -182,7 +182,7 @@ bool MyApp::OnInit()
     file_menu->Append(MINIMAL_ABOUT, "&About");
     file_menu->Append(MINIMAL_QUIT, "E&xit");
 
-    wxMenuBar *menu_bar = new wxMenuBar;
+    wxMenuBar *menu_bar = new wxMenuBar( wxMB_DOCKABLE );
     menu_bar->Append(file_menu, "&File");
 
 #if wxUSE_TOOLTIPS
index 16c2120ba9a4361a9a334d6fd2a03bfa110decef..4b4f1104b6331d1eada114bb60723a2ae0a8be6f 100644 (file)
@@ -114,8 +114,6 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
   image.LoadFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG );
   my_square = new wxBitmap( image.ConvertToBitmap() );
   
-  (void)new wxTextCtrl( this, -1, "", wxPoint(10,200), wxSize(120,-1) );
-
   CreateAntiAliasedBitmap();
 }
 
index 0aaa5d908d0ca2e1005e3045bf39529b36214ef0..08cf535a6a643046dfacf4de841ffe404431b5a0 100644 (file)
@@ -1277,6 +1277,10 @@ wxImage::wxImage( const wxBitmap &bitmap )
 #include "gdk/gdk.h"
 #include "gdk/gdkx.h"
 
+#if (GTK_MINOR_VERSION > 0)
+#include "gdk/gdkrgb.h"
+#endif
+
 wxBitmap wxImage::ConvertToBitmap() const
 {
     wxBitmap bitmap;
@@ -1289,14 +1293,54 @@ wxBitmap wxImage::ConvertToBitmap() const
     bitmap.SetHeight( height );
     bitmap.SetWidth( width );
     
-    // Create picture
+    bitmap.SetPixmap( gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 ) );
+
+     // Retrieve depth
+    
+    GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() );
+    if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
+    int bpp = visual->depth;
+    
+    bitmap.SetDepth( bpp );
+    
+    if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
+    if (bpp < 8) bpp = 8;
+    
+#if (GTK_MINOR_VERSION > 0)
+
+    if (!HasMask() && (bpp > 8))
+    {
+        static bool s_hasInitialized = FALSE;
+       
+       if (!s_hasInitialized)
+       {
+           gdk_rgb_init();
+           s_hasInitialized = TRUE;
+       }
+       
+        GdkGC *gc = gdk_gc_new( bitmap.GetPixmap() );
+       
+       gdk_draw_rgb_image( bitmap.GetPixmap(),
+                           gc,
+                           0, 0,
+                           width, height,
+                           GDK_RGB_DITHER_NONE,
+                           GetData(),
+                           width*3 );
+                           
+        gdk_gc_unref( gc );
+                           
+       return bitmap;
+    }
+    
+#endif
+    
+    // Create picture image
     
     GdkImage *data_image =
         gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height );
     
-    bitmap.SetPixmap( gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 ) );
-    
-    // Create mask
+    // Create mask image
     
     GdkImage *mask_image = (GdkImage*) NULL;
     
@@ -1312,17 +1356,6 @@ wxBitmap wxImage::ConvertToBitmap() const
         bitmap.SetMask( mask );
     }
     
-    // Retrieve depth
-    
-    GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() );
-    if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
-    int bpp = visual->depth;
-    
-    bitmap.SetDepth( bpp );
-    
-    if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
-    if (bpp < 8) bpp = 8;
-    
     // Render
     
     enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };