From f38485afa5317fd409fbae3d64e67453868ba358 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 25 Mar 2016 23:12:40 +0100 Subject: [PATCH] Modified drawing sample to demonstrate drawing graphics bitmaps. Draw graphics bitmap and sub-bitmap (on Graphics screen) to present wxGraphicsBitmap support. --- samples/drawing/drawing.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 96b09aab91..84a8d5a5de 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -1172,6 +1172,19 @@ void MyCanvas::DrawGraphics(wxGraphicsContext* gc) gc->DrawRectangle(BASE2, BASE2, 100, 100); gc->DrawBitmap(m_smile_bmp, BASE2, BASE2, 100, 100); gc->PopState(); + + // Draw graphics bitmap and its subbitmap + gc->PushState(); + gc->Translate(300, 400); + gc->DrawText(wxS("Smiley as a graphics bitmap"), 0, 0); + + wxGraphicsBitmap gbmp1 = gc->CreateBitmap(m_smile_bmp); + gc->DrawBitmap(gbmp1, 0, BASE2, 50, 50); + int bmpw = m_smile_bmp.GetWidth(); + int bmph = m_smile_bmp.GetHeight(); + wxGraphicsBitmap gbmp2 = gc->CreateSubBitmap(gbmp1, 0, bmph/5, bmpw/2, bmph/2); + gc->DrawBitmap(gbmp2, 80, BASE2, 50, 50*(bmph/2)/(bmpw/2)); + gc->PopState(); } #endif // wxUSE_GRAPHICS_CONTEXT