#include "smile.xbm"
#include "smile.xpm"
+#include "cursor_png.c"
#include "canvas.h"
wxMemoryDC dc;
dc.SelectObject( bitmap );
- dc.SetBrush( wxBrush( wxT("orange"), wxSOLID ) );
+ dc.SetBrush( wxBrush( wxS("orange") ) );
dc.SetPen( *wxBLACK_PEN );
dc.DrawRectangle( 0, 0, 100, 100 );
dc.SetBrush( *wxWHITE_BRUSH );
free(data);
}
+
+ // This macro loads PNG from either resources on the platforms that support
+ // this (Windows and OS X) or from in-memory data (coming from cursor_png.c
+ // included above in our case).
+ my_png_from_res = wxBITMAP_PNG(cursor);
+
+ // This one always loads PNG from memory but exists for consistency with
+ // the above one and also because it frees you from the need to specify the
+ // length explicitly, without it you'd have to do it and also spell the
+ // array name in full, like this:
+ //
+ // my_png_from_mem = wxBitmap::NewFromPNGData(cursor_png, WXSIZEOF(cursor_png));
+ my_png_from_mem = wxBITMAP_PNG_FROM_DATA(cursor);
}
MyCanvas::~MyCanvas()
dc.DrawBitmap( my_square, 30, 30 );
dc.DrawText( wxT("Drawn directly"), 150, 10 );
- dc.SetBrush( wxBrush( wxT("orange"), wxSOLID ) );
+ dc.SetBrush( wxBrush( wxS("orange") ) );
dc.SetPen( *wxBLACK_PEN );
dc.DrawRectangle( 150, 30, 100, 100 );
dc.SetBrush( *wxWHITE_BRUSH );
dc.DrawBitmap( my_horse_ani[i], 230 + i * 2 * my_horse_ani[i].GetWidth() , 2420, true );
}
}
+
+ dc.DrawText("PNG from resources", 30, 2460);
+ if ( my_png_from_res.IsOk() )
+ dc.DrawBitmap(my_png_from_res, 30, 2480, true);
+ dc.DrawText("PNG from memory", 230, 2460);
+ if ( my_png_from_mem.IsOk() )
+ dc.DrawBitmap(my_png_from_mem, 230, 2480, true);
}
void MyCanvas::CreateAntiAliasedBitmap()