Skip to content

Commit

Permalink
c++: fix MSVC compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
axxel committed Dec 13, 2023
1 parent 66afdf1 commit 847319a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ float IsPattern(const PatternView& view, const FixedPattern<LEN, SUM, false>& pa
return 0;

const float_t moduleSize = (modSize[0] + modSize[1]) / 2;
return moduleSize;
return static_cast<float>(moduleSize);
}

int width = view.sum(LEN);
Expand Down
2 changes: 1 addition & 1 deletion core/src/oned/ODDXFilmEdgeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Result DXFilmEdgeReader::decodePattern(int rowNumber, PatternView& next, std::un
BitArray dataBits;
while (next.isValid(1) && dataBits.size() < clock->dataLength()) {

int modules = next[0] / clock->moduleSize() + 0.5;
int modules = int(next[0] / clock->moduleSize() + 0.5);
// even index means we are at a bar, otherwise at a space
dataBits.appendBits(next.index() % 2 == 0 ? 0xFFFFFFFF : 0x0, modules);

Expand Down
2 changes: 1 addition & 1 deletion core/src/qrcode/QRDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ DecoderResult DecodeBitStream(ByteArray&& bytes, const Version& version, ErrorCo
}
}
}
} catch (std::out_of_range& e) { // see BitSource::readBits
} catch (std::out_of_range&) { // see BitSource::readBits
error = FormatError("Truncated bit stream");
} catch (Error e) {
error = std::move(e);
Expand Down
8 changes: 4 additions & 4 deletions core/src/qrcode/QRDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PatternView FindPattern(const PatternView& view)
// perform a fast plausability test for 1:1:3:1:1 pattern
if (view[2] < 2 * std::max(view[0], view[4]) || view[2] < std::max(view[1], view[3]))
return 0.f;
return IsPattern<E2E>(view, PATTERN, spaceInPixel, 0.1); // the requires 4, here we accept almost 0
return IsPattern<E2E>(view, PATTERN, spaceInPixel, 0.1f); // the requires 4, here we accept almost 0
});
}

Expand Down Expand Up @@ -633,7 +633,7 @@ DetectorResult DetectPureRMQR(const BitMatrix& image)
if (!IsPattern(subdiagonal, SUBPATTERN))
return {};

float moduleSize = Reduce(diagonal) + Reduce(subdiagonal);
double moduleSize = Reduce(diagonal) + Reduce(subdiagonal);

// Horizontal timing patterns
for (auto [p, d] : {std::pair(tr, PointI{-1, 0}), {bl, {1, 0}}, {tl, {1, 0}}, {br, {-1, 0}}}) {
Expand Down Expand Up @@ -779,9 +779,9 @@ DetectorResult SampleRMQR(const BitMatrix& image, const ConcentricPattern& fp)
auto br = Center(b);
// rotate points such that topLeft of a is furthest away from b and topLeft of b is closest to a
auto dist2B = [c = br](auto a, auto b) { return distance(a, c) < distance(b, c); };
auto offsetA = std::max_element(a.begin(), a.end(), dist2B) - a.begin();
auto offsetA = narrow_cast<int>(std::max_element(a.begin(), a.end(), dist2B) - a.begin());
auto dist2A = [c = tl](auto a, auto b) { return distance(a, c) < distance(b, c); };
auto offsetB = std::min_element(b.begin(), b.end(), dist2A) - b.begin();
auto offsetB = narrow_cast<int>(std::min_element(b.begin(), b.end(), dist2A) - b.begin());

a = RotatedCorners(a, offsetA);
b = RotatedCorners(b, offsetB);
Expand Down

0 comments on commit 847319a

Please sign in to comment.