diff --git a/isobus/src/isobus_virtual_terminal_working_set_base.cpp b/isobus/src/isobus_virtual_terminal_working_set_base.cpp index dab35057..e964dbea 100644 --- a/isobus/src/isobus_virtual_terminal_working_set_base.cpp +++ b/isobus/src/isobus_virtual_terminal_working_set_base.cpp @@ -2210,12 +2210,14 @@ namespace isobus { if (iopLength >= tempObject->get_number_of_bytes_in_raw_data()) { + std::uint32_t dataCounter = 0; switch (tempObject->get_format()) { case PictureGraphic::Format::EightBitColour: { tempObject->set_raw_data(iopData, tempObject->get_number_of_bytes_in_raw_data()); iopData += tempObject->get_number_of_bytes_in_raw_data(); + dataCounter += tempObject->get_number_of_bytes_in_raw_data(); iopLength -= tempObject->get_number_of_bytes_in_raw_data(); } break; @@ -2244,6 +2246,7 @@ namespace isobus lineAmountLeft = tempObject->get_actual_width(); } iopData++; + dataCounter++; iopLength--; } } @@ -2271,11 +2274,18 @@ namespace isobus lineAmountLeft = tempObject->get_actual_width(); } iopData++; + dataCounter++; iopLength--; } } break; } + + if (dataCounter < tempObject->get_number_of_bytes_in_raw_data()) + { + iopData += (tempObject->get_number_of_bytes_in_raw_data() - dataCounter); + iopLength += (tempObject->get_number_of_bytes_in_raw_data() - dataCounter); + } } else { @@ -2294,9 +2304,7 @@ namespace isobus CANStackLogger::warn("[WS]: Skipped parsing macro reference in picture graphic object (todo)"); } - if ((0 != tempObject->get_actual_width()) && - (0 != tempObject->get_actual_height()) && - (tempObject->get_raw_data().size() == (tempObject->get_actual_width() * tempObject->get_actual_height()))) + if (tempObject->get_raw_data().size() <= (tempObject->get_actual_width() * tempObject->get_actual_height())) { retVal = true; }