+void MyCanvas::CreateAntiAliasedBitmap()
+{
+ wxBitmap bitmap( 300, 300 );
+
+ wxMemoryDC dc;
+
+ dc.SelectObject( bitmap );
+
+ dc.Clear();
+
+ dc.SetFont( wxFont( 24, wxDECORATIVE, wxDEFAULT, wxDEFAULT ) );
+ dc.SetTextForeground( "RED" );
+ dc.DrawText( "This is anti-aliased Text.", 20, 20 );
+ dc.DrawText( "And a Rectangle.", 20, 60 );
+
+ dc.SetBrush( *wxRED_BRUSH );
+ dc.DrawRoundedRectangle( 20, 100, 200, 180, 20 );
+
+ wxImage original( bitmap );
+ wxImage anti( 150, 150 );
+
+ /* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */
+
+ for (int y = 1; y < 149; y++)
+ for (int x = 1; x < 149; x++)
+ {
+ int red = original.GetRed( x*2, y*2 ) +
+ original.GetRed( x*2-1, y*2 ) +
+ original.GetRed( x*2, y*2+1 ) +
+ original.GetRed( x*2+1, y*2+1 );
+ red = red/4;
+
+ int green = original.GetGreen( x*2, y*2 ) +
+ original.GetGreen( x*2-1, y*2 ) +
+ original.GetGreen( x*2, y*2+1 ) +
+ original.GetGreen( x*2+1, y*2+1 );
+ green = green/4;
+
+ int blue = original.GetBlue( x*2, y*2 ) +
+ original.GetBlue( x*2-1, y*2 ) +
+ original.GetBlue( x*2, y*2+1 ) +
+ original.GetBlue( x*2+1, y*2+1 );
+ blue = blue/4;
+ anti.SetRGB( x, y, red, green, blue );
+ }
+ my_anti = new wxBitmap( anti.ConvertToBitmap() );