Some side tracking fixing undefined behaviour and memory vulnurabilities
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace ptprnt::graphics {
|
||||
@@ -41,9 +42,9 @@ std::vector<uint8_t> Monochrome::get() {
|
||||
|
||||
unsigned int outIndex = 0;
|
||||
|
||||
for (unsigned int byteNum = 0; byteNum < mPixels.size(); byteNum += 8) {
|
||||
for (unsigned int bitNo = 0; bitNo < 8; bitNo++) {
|
||||
if (mPixels[byteNum + bitNo] > mThreshhold) {
|
||||
for (unsigned int byteNo = 0; byteNo < mPixels.size(); byteNo += 8) {
|
||||
for (unsigned int bitNo = 0; bitNo <= 7 && (byteNo + bitNo < mPixels.size()); bitNo++) {
|
||||
if (mPixels[byteNo + bitNo] > mThreshhold) {
|
||||
outPixels[outIndex] |= (1 << (7 - bitNo));
|
||||
} else {
|
||||
outPixels[outIndex] &= ~(1 << (7 - bitNo));
|
||||
|
Reference in New Issue
Block a user