]> git.saurik.com Git - wxWidgets.git/commitdiff
Show grey version of image with alpha channel.
authorWłodzimierz Skiba <abx@abx.art.pl>
Wed, 7 Jun 2006 16:59:33 +0000 (16:59 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Wed, 7 Jun 2006 16:59:33 +0000 (16:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39620 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/image/image.cpp
samples/image/makefile.wat

index 05912b5e49531ab3eb386b99118684ded4d23b00..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 ;
@@ -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);
index 2424d6fdba4b22df404c62eefece29502a704de2..6c7fda3204d325c6078d33ca6568facd8f3ee41b 100644 (file)
@@ -240,14 +240,14 @@ $(OBJS)\image.exe :  $(IMAGE_OBJECTS) $(OBJS)\image_image.res
        @%append $(OBJS)\image.lbc option caseexact
        @%append $(OBJS)\image.lbc $(LDFLAGS) $(__DEBUGINFO_1)  libpath $(LIBDIRNAME) system nt_win ref '_WinMain@16'
        @for %i in ($(IMAGE_OBJECTS)) do @%append $(OBJS)\image.lbc file %i
-       @for %i in ( $(__WXLIB_CORE_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib  wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE)  kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib ) do @%append $(OBJS)\image.lbc library %i
+       @for %i in ( $(__WXLIB_CORE_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p)  wxzlib$(WXDEBUGFLAG).lib  wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE)  kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib) do @%append $(OBJS)\image.lbc library %i
        @%append $(OBJS)\image.lbc option resource=$(OBJS)\image_image.res
        @for %i in () do @%append $(OBJS)\image.lbc option stack=%i
        wlink @$(OBJS)\image.lbc
 
 data : .SYMBOLIC 
        if not exist $(OBJS) mkdir $(OBJS)
-       for %f in (horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.xpm horse.cur horse.ico horse3.ani smile.xbm) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
+       for %f in (horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.xpm horse.cur horse.ico horse3.ani smile.xbm toucan.png cmyk.jpg) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
 
 $(OBJS)\image_image.obj :  .AUTODEPEND .\image.cpp
        $(CXX) -bt=nt -zq -fo=$^@ $(IMAGE_CXXFLAGS) $<