Prepare canvas for rendering to bitmap only

This commit is contained in:
Tiberiu Chibici 2014-10-11 10:27:15 +03:00
parent 7691a3c326
commit 800c49e3f9
5 changed files with 16 additions and 0 deletions

View File

@ -69,6 +69,7 @@ public:
// matched by a corresponding call to ReleaseDC(). While in the Gdiplus context, non-const // matched by a corresponding call to ReleaseDC(). While in the Gdiplus context, non-const
// member functions of this class must not be called. // member functions of this class must not be called.
virtual HDC GetDC() = 0; virtual HDC GetDC() = 0;
virtual HBITMAP GetBitmap() = 0;
virtual void ReleaseDC(HDC dc) = 0; virtual void ReleaseDC(HDC dc) = 0;
// The Create* functions allocate objects specific to this Canvas object. // The Create* functions allocate objects specific to this Canvas object.

View File

@ -210,6 +210,13 @@ HDC CanvasD2D::GetDC()
return dcMemory; return dcMemory;
} }
HBITMAP CanvasD2D::GetBitmap()
{
EndTargetDraw();
return m_Bitmap.GetHandle();
}
void CanvasD2D::ReleaseDC(HDC dc) void CanvasD2D::ReleaseDC(HDC dc)
{ {
DeleteDC(dc); DeleteDC(dc);

View File

@ -51,6 +51,7 @@ public:
virtual void EndGdiplusContext() override; virtual void EndGdiplusContext() override;
virtual HDC GetDC() override; virtual HDC GetDC() override;
virtual HBITMAP GetBitmap() override;
virtual void ReleaseDC(HDC dc) override; virtual void ReleaseDC(HDC dc) override;
virtual FontCollection* CreateFontCollection() override { return new FontCollectionD2D(); } virtual FontCollection* CreateFontCollection() override { return new FontCollectionD2D(); }

View File

@ -99,6 +99,12 @@ HDC CanvasGDIP::GetDC()
return dcMemory; return dcMemory;
} }
HBITMAP CanvasGDIP::GetBitmap()
{
return m_DIBSection;
}
void CanvasGDIP::ReleaseDC(HDC dc) void CanvasGDIP::ReleaseDC(HDC dc)
{ {
DeleteDC(dc); DeleteDC(dc);

View File

@ -42,6 +42,7 @@ public:
virtual void EndGdiplusContext() override; virtual void EndGdiplusContext() override;
virtual HDC GetDC() override; virtual HDC GetDC() override;
virtual HBITMAP GetBitmap() override;
virtual void ReleaseDC(HDC dc) override; virtual void ReleaseDC(HDC dc) override;
virtual FontCollection* CreateFontCollection() override { return new FontCollectionGDIP(); } virtual FontCollection* CreateFontCollection() override { return new FontCollectionGDIP(); }