diff --git a/src/DMD.cpp b/src/DMD.cpp index c7f6ab6..59c894d 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -519,7 +519,7 @@ void DMD::ZeDMDThread() // ZeDMD HD supports 256 * 64 pixels. uint8_t rgb24Data[256 * 64 * 3]; - AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, width * height * 3, palette, + AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, width * height, palette, m_updateBuffer[bufferPosition]->depth); m_pZeDMD->RenderRgb24(rgb24Data); } @@ -648,7 +648,7 @@ void DMD::PixelcadeDMDThread() if (m_updateBuffer[bufferPosition]->mode == DMDMode::RGB24) { uint8_t rgb24Data[128 * 32 * 3]; - AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, length * 3, palette, + AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, length, palette, m_updateBuffer[bufferPosition]->depth); for (int i = 0; i < length; i++) { @@ -807,7 +807,7 @@ void DMD::RGB24DMDThread() m_updateBuffer[bufferPosition]->g, m_updateBuffer[bufferPosition]->b); } - AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, length * 3, palette, + AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, length, palette, m_updateBuffer[bufferPosition]->depth); for (RGB24DMD* pRGB24DMD : m_rgb24DMDs) @@ -972,7 +972,7 @@ void DMD::AdjustRGB24Depth(uint8_t* pData, uint8_t* pDstData, int length, uint8_ } else { - memcpy(pDstData, pData, length); + memcpy(pDstData, pData, length * 3); } } diff --git a/src/test.cpp b/src/test.cpp index a923734..eeec6f5 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -174,6 +174,7 @@ int main(int argc, const char* argv[]) snprintf(filename, 28, "test/rgb565_%dx%d/%04d.raw", width, height, i); printf("Render raw: %s\n", filename); fileptr = fopen(filename, "rb"); + if (!fileptr) continue; fread(buffer, size, 1, fileptr); fclose(fileptr);