+ dc.DrawText(_T("XPM bitmap"), 30, 2230 );
+ if ( m_bmpSmileXpm.Ok() )
+ dc.DrawBitmap(m_bmpSmileXpm, 30, 2250, true);
+
+ dc.DrawText(_T("XPM icon"), 110, 2230 );
+ if ( m_iconSmileXpm.Ok() )
+ dc.DrawIcon(m_iconSmileXpm, 110, 2250);
+
+ // testing icon -> bitmap conversion
+ wxBitmap to_blit( m_iconSmileXpm );
+ if (to_blit.Ok())
+ {
+ dc.DrawText( _T("SubBitmap"), 170, 2230 );
+ wxBitmap sub = to_blit.GetSubBitmap( wxRect(0,0,15,15) );
+ if (sub.Ok())
+ dc.DrawBitmap( sub, 170, 2250, true );
+
+ dc.DrawText( _T("Enlarged"), 250, 2230 );
+ dc.SetUserScale( 1.5, 1.5 );
+ dc.DrawBitmap( to_blit, (int)(250/1.5), (int)(2250/1.5), true );
+ dc.SetUserScale( 2, 2 );
+ dc.DrawBitmap( to_blit, (int)(300/2), (int)(2250/2), true );
+ dc.SetUserScale( 1.0, 1.0 );
+
+ dc.DrawText( _T("Blit"), 400, 2230);
+ wxMemoryDC blit_dc;
+ blit_dc.SelectObject( to_blit );
+ dc.Blit( 400, 2250, to_blit.GetWidth(), to_blit.GetHeight(), &blit_dc, 0, 0, wxCOPY, true );
+ dc.SetUserScale( 1.5, 1.5 );
+ dc.Blit( (int)(450/1.5), (int)(2250/1.5), to_blit.GetWidth(), to_blit.GetHeight(), &blit_dc, 0, 0, wxCOPY, true );
+ dc.SetUserScale( 2, 2 );
+ dc.Blit( (int)(500/2), (int)(2250/2), to_blit.GetWidth(), to_blit.GetHeight(), &blit_dc, 0, 0, wxCOPY, true );
+ dc.SetUserScale( 1.0, 1.0 );
+ }
+
+ dc.DrawText( _T("ICO handler (1st image)"), 30, 2290 );
+ if (my_horse_ico32 && my_horse_ico32->Ok())
+ dc.DrawBitmap( *my_horse_ico32, 30, 2330, true );
+
+ dc.DrawText( _T("ICO handler (2nd image)"), 230, 2290 );
+ if (my_horse_ico16 && my_horse_ico16->Ok())
+ dc.DrawBitmap( *my_horse_ico16, 230, 2330, true );
+
+ dc.DrawText( _T("ICO handler (best image)"), 430, 2290 );
+ if (my_horse_ico && my_horse_ico->Ok())
+ dc.DrawBitmap( *my_horse_ico, 430, 2330, true );
+
+ dc.DrawText( _T("CUR handler"), 30, 2390 );
+ if (my_horse_cur && my_horse_cur->Ok())
+ {
+ dc.DrawBitmap( *my_horse_cur, 30, 2420, true );
+ dc.SetPen (*wxRED_PEN);
+ dc.DrawLine (xH-10,yH,xH+10,yH);
+ dc.DrawLine (xH,yH-10,xH,yH+10);
+ }
+ dc.DrawText( _T("ANI handler"), 230, 2390 );
+ int i ;
+ for (i=0; i < m_ani_images; i ++)
+ if (my_horse_ani[i].Ok())
+ {
+ dc.DrawBitmap( my_horse_ani[i], 230 + i * 2 * my_horse_ani[i].GetWidth() , 2420, true );
+ }
+}
+
+void MyCanvas::CreateAntiAliasedBitmap()
+{
+ wxBitmap bitmap( 300, 300 );
+
+ wxMemoryDC dc;
+
+ dc.SelectObject( bitmap );
+
+ dc.Clear();
+
+ dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL) );
+ dc.SetTextForeground( wxT("RED") );
+ dc.DrawText( _T("This is anti-aliased Text."), 20, 20 );
+ dc.DrawText( _T("And a Rectangle."), 20, 60 );
+
+ dc.SetBrush( *wxRED_BRUSH );
+ dc.SetPen( *wxTRANSPARENT_PEN );
+ dc.DrawRoundedRectangle( 20, 100, 200, 180, 20 );
+
+ wxImage original= bitmap.ConvertToImage();
+ 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, (unsigned char)red, (unsigned char)green, (unsigned char)blue );
+ }
+ my_anti = new wxBitmap(anti);