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
// 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.

View File

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

View File

@ -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(); }

View File

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

View File

@ -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(); }