From 800c49e3f9315c35d755376ff61c44d6e15514b6 Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Sat, 11 Oct 2014 10:27:15 +0300 Subject: [PATCH] Prepare canvas for rendering to bitmap only --- Common/Gfx/Canvas.h | 1 + Common/Gfx/CanvasD2D.cpp | 7 +++++++ Common/Gfx/CanvasD2D.h | 1 + Common/Gfx/CanvasGDIP.cpp | 6 ++++++ Common/Gfx/CanvasGDIP.h | 1 + 5 files changed, 16 insertions(+) diff --git a/Common/Gfx/Canvas.h b/Common/Gfx/Canvas.h index 03d80209..0e3e7563 100644 --- a/Common/Gfx/Canvas.h +++ b/Common/Gfx/Canvas.h @@ -69,6 +69,7 @@ public: // matched by a corresponding call to ReleaseDC(). While in the Gdiplus context, non-const // member functions of this class must not be called. virtual HDC GetDC() = 0; + virtual HBITMAP GetBitmap() = 0; virtual void ReleaseDC(HDC dc) = 0; // The Create* functions allocate objects specific to this Canvas object. diff --git a/Common/Gfx/CanvasD2D.cpp b/Common/Gfx/CanvasD2D.cpp index 8f390228..c8787332 100644 --- a/Common/Gfx/CanvasD2D.cpp +++ b/Common/Gfx/CanvasD2D.cpp @@ -210,6 +210,13 @@ HDC CanvasD2D::GetDC() return dcMemory; } +HBITMAP CanvasD2D::GetBitmap() +{ + EndTargetDraw(); + + return m_Bitmap.GetHandle(); +} + void CanvasD2D::ReleaseDC(HDC dc) { DeleteDC(dc); diff --git a/Common/Gfx/CanvasD2D.h b/Common/Gfx/CanvasD2D.h index b30465aa..c375e561 100644 --- a/Common/Gfx/CanvasD2D.h +++ b/Common/Gfx/CanvasD2D.h @@ -51,6 +51,7 @@ public: virtual void EndGdiplusContext() override; virtual HDC GetDC() override; + virtual HBITMAP GetBitmap() override; virtual void ReleaseDC(HDC dc) override; virtual FontCollection* CreateFontCollection() override { return new FontCollectionD2D(); } diff --git a/Common/Gfx/CanvasGDIP.cpp b/Common/Gfx/CanvasGDIP.cpp index be6a70ad..e3df3cb1 100644 --- a/Common/Gfx/CanvasGDIP.cpp +++ b/Common/Gfx/CanvasGDIP.cpp @@ -99,6 +99,12 @@ HDC CanvasGDIP::GetDC() return dcMemory; } +HBITMAP CanvasGDIP::GetBitmap() +{ + return m_DIBSection; +} + + void CanvasGDIP::ReleaseDC(HDC dc) { DeleteDC(dc); diff --git a/Common/Gfx/CanvasGDIP.h b/Common/Gfx/CanvasGDIP.h index a989cbca..e3c83a90 100644 --- a/Common/Gfx/CanvasGDIP.h +++ b/Common/Gfx/CanvasGDIP.h @@ -42,6 +42,7 @@ public: virtual void EndGdiplusContext() override; virtual HDC GetDC() override; + virtual HBITMAP GetBitmap() override; virtual void ReleaseDC(HDC dc) override; virtual FontCollection* CreateFontCollection() override { return new FontCollectionGDIP(); }