]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/image/image.cpp
fixed bad pane name
[wxWidgets.git] / samples / image / image.cpp
index edb79dd9da24a4b8411ef8ddd298649c390af5ea..e52c7e6c08790c3ef9cf33c6f9bd147274a223b8 100644 (file)
@@ -17,7 +17,7 @@
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+    #include "wx/wx.h"
 #endif
 
 #include "wx/image.h"
@@ -89,6 +89,7 @@ public:
     wxBitmap my_toucan_flipped_horiz;
     wxBitmap my_toucan_flipped_vert;
     wxBitmap my_toucan_flipped_both;
+    wxBitmap my_toucan_grey;
     wxBitmap my_toucan_head;
 
     int xH, yH ;
@@ -170,7 +171,7 @@ public:
                                                 wxT("PCX files (*.pcx)|*.pcx|")
                                                 wxT("ICO files (*.ico)|*.ico|")
                                                 wxT("CUR files (*.cur)|*.cur"),
-                                                wxSAVE,
+                                                wxFD_SAVE,
                                                 this);
 
         if ( savefilename.empty() )
@@ -468,11 +469,15 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
     else
         my_horse_png = wxBitmap( image );
 
-    image = wxImage(wxT("toucan.png"));
-    my_toucan = wxBitmap(image);
+    if ( !image.LoadFile( dir + _T("toucan.png")) )
+        wxLogError(wxT("Can't load PNG image"));
+    else
+        my_toucan = wxBitmap(image);
+
     my_toucan_flipped_horiz = wxBitmap(image.Mirror(true));
     my_toucan_flipped_vert = wxBitmap(image.Mirror(false));
     my_toucan_flipped_both = wxBitmap(image.Mirror(true).Mirror(false));
+    my_toucan_grey = wxBitmap(image.ConvertToGreyscale());
     my_toucan_head = wxBitmap(image.GetSubImage(wxRect(40, 7, 80, 60)));
 
 #endif // wxUSE_LIBPNG
@@ -752,6 +757,10 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
         dc.DrawText(wxT("Flipped both h&v"), x+50, y);
         dc.DrawBitmap(my_toucan_flipped_both, x, y+15);
 
+        y += yy;
+        dc.DrawText(wxT("In greyscale"), x+50, y);
+        dc.DrawBitmap(my_toucan_grey, x, y+15);
+
         y += yy;
         dc.DrawText(wxT("Toucan's head"), x+50, y);
         dc.DrawBitmap(my_toucan_head, x, y+15);
@@ -765,7 +774,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
         dc.SetTextBackground( _T("RED") );
         dc.DrawBitmap( my_smile_xbm, 30, 2010 );
 
-        dc.SetTextForeground( wxT("BLACK") );
+        dc.SetTextForeground( *wxBLACK );
         dc.DrawText( _T("After wxImage conversion"), 150, 1975 );
         dc.DrawText( _T("(red on white)"), 150, 1990 );
         dc.SetTextForeground( wxT("RED") );
@@ -776,7 +785,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
                wxRED_PEN->GetColour().Green(),
                wxRED_PEN->GetColour().Blue() );
         dc.DrawBitmap( wxBitmap(i), 150, 2010, true );
-        dc.SetTextForeground( wxT("BLACK") );
+        dc.SetTextForeground( *wxBLACK );
     }
 
 
@@ -805,7 +814,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
         dc.SetTextBackground( wxT("GREEN") );
         dc.DrawBitmap( mono, 30, 2130 );
 
-        dc.SetTextForeground( wxT("BLACK") );
+        dc.SetTextForeground( *wxBLACK );
         dc.DrawText( _T("After wxImage conversion"), 150, 2095 );
         dc.DrawText( _T("(red on white)"), 150, 2110 );
         dc.SetTextForeground( wxT("RED") );
@@ -816,7 +825,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
                wxRED_PEN->GetColour().Green(),
                wxRED_PEN->GetColour().Blue() );
         dc.DrawBitmap( wxBitmap(i), 150, 2130, true );
-        dc.SetTextForeground( wxT("BLACK") );
+        dc.SetTextForeground( *wxBLACK );
     }
 
     // For testing transparency