added various casts to avoid LGTM warning

This commit is contained in:
Nikolaos Ftylitakis 2021-08-07 22:52:41 +03:00
parent 0f768f98e9
commit 777391c1cf
5 changed files with 7 additions and 7 deletions

View File

@ -195,7 +195,7 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin)
const int width = getWidth();
const int height = getHeight();
imageBytes = QSharedPointer<std::vector<zxing::byte>>(new std::vector<zxing::byte>(height*width));
imageBytes = QSharedPointer<std::vector<zxing::byte>>(new std::vector<zxing::byte>((size_t)height * (size_t)width));
imageBytesPerRow = QSharedPointer<std::vector<QSharedPointer<std::vector<zxing::byte>>>>(new std::vector<QSharedPointer<std::vector<zxing::byte>>>(height));
zxing::byte* m = &(*imageBytes)[0];

View File

@ -37,7 +37,7 @@ void BitMatrix::init(int width, int height) {
this->width = width;
this->height = height;
this->rowSize = (width + 31) >> 5;
bits.reset(new std::vector<int>(rowSize * height));
bits.reset(new std::vector<int>((size_t)rowSize * (size_t)height));
}
BitMatrix::BitMatrix(int dimension) {

View File

@ -64,7 +64,7 @@ QSharedPointer<std::vector<zxing::byte>> GreyscaleLuminanceSource::getMatrix() c
int size = getWidth() * getHeight();
QSharedPointer<std::vector<zxing::byte>> result (new std::vector<zxing::byte>(size));
for (int row = 0; row < getHeight(); row++) {
memcpy(&(*result)[row * getWidth()], &(*greyData_)[(top_ + row) * dataWidth_ + left_], getWidth());
memcpy(&(*result)[(size_t)row * (size_t)getWidth()], &(*greyData_)[(top_ + row) * dataWidth_ + left_], getWidth());
}
return result;
}

View File

@ -69,9 +69,9 @@ GreyscaleRotatedLuminanceSource::getRow(int y, QSharedPointer<std::vector<zxing:
}
QSharedPointer<std::vector<zxing::byte>> GreyscaleRotatedLuminanceSource::getMatrix() const {
QSharedPointer<std::vector<zxing::byte>> result (new std::vector<zxing::byte>(getWidth() * getHeight()));
QSharedPointer<std::vector<zxing::byte>> result (new std::vector<zxing::byte>((size_t)getWidth() * (size_t)getHeight()));
for (int y = 0; y < getHeight(); y++) {
zxing::byte* row = &(*result)[y * getWidth()];
zxing::byte* row = &(*result)[(size_t)y * (size_t)getWidth()];
int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_));
for (int x = 0; x < getWidth(); x++) {
row[x] = (*greyData_)[offset];

View File

@ -117,7 +117,7 @@ HybridBinarizer::calculateThresholdForBlock(QSharedPointer<std::vector<zxing::by
int top = cap(y, 2, subHeight - 3);
int sum = 0;
for (int z = -2; z <= 2; z++) {
int *blackRow = &(*blackPoints)[(top + z) * subWidth];
int *blackRow = &(*blackPoints)[(size_t)(top + z) * (size_t)subWidth];
sum += blackRow[left - 2];
sum += blackRow[left - 1];
sum += blackRow[left];
@ -164,7 +164,7 @@ QSharedPointer<std::vector<int>> HybridBinarizer::calculateBlackPoints(QSharedPo
int height) {
const int minDynamicRange = 24;
QSharedPointer<std::vector<int>> blackPoints (new std::vector<int>(subHeight * subWidth));
QSharedPointer<std::vector<int>> blackPoints (new std::vector<int>((size_t)subHeight * (size_t)subWidth));
for (int y = 0; y < subHeight; y++) {
int yoffset = y << BLOCK_SIZE_POWER;
int maxYOffset = height - BLOCK_SIZE;