diff --git a/README.md b/README.md index cc9dcfc..3679765 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ void test() if (pRGB24Data) { // Render pRGB24Data } + + pDmd->DestroyVirtualDMD(pVirtualDMD); } ``` diff --git a/include/DMDUtil/DMD.h b/include/DMDUtil/DMD.h index 8becdf7..afff259 100644 --- a/include/DMDUtil/DMD.h +++ b/include/DMDUtil/DMD.h @@ -61,6 +61,7 @@ class DMDUTILAPI DMD int GetHeight() const { return m_height; } int GetLength() const { return m_length; } VirtualDMD* CreateVirtualDMD(); + bool DestroyVirtualDMD(VirtualDMD* pVirtualDMD); void UpdateData(const uint8_t* pData, int depth, uint8_t r, uint8_t g, uint8_t b); void UpdateRGB24Data(const uint8_t* pData, int depth, uint8_t r, uint8_t g, uint8_t b); void UpdateAlphaNumericData(AlphaNumericLayout layout, const uint16_t* pData1, const uint16_t* pData2, uint8_t r, diff --git a/src/DMD.cpp b/src/DMD.cpp index 7bb10c7..4cb8978 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -121,6 +121,19 @@ VirtualDMD* DMD::CreateVirtualDMD() return pVirtualDMD; } +bool DMD::DestroyVirtualDMD(VirtualDMD* pVirtualDMD) +{ + auto it = std::find(m_virtualDMDs.begin(), m_virtualDMDs.end(), pVirtualDMD); + if (it != m_virtualDMDs.end()) + { + m_virtualDMDs.erase(it); + delete pVirtualDMD; + + return true; + } + return false; +} + void DMD::UpdateData(const uint8_t* pData, int depth, uint8_t r, uint8_t g, uint8_t b) { DMDUpdate* const pUpdate = new DMDUpdate();