Mercurial > hg > orthanc
comparison Core/Images/ImageProcessing.cpp @ 3585:113a9643e8bb
Suppressed a few warnings when building with emscripten (clang) + numeric truncation warnings
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 02 Dec 2019 10:59:40 +0100 |
parents | 2999a6e9456b |
children | 4066998150ef |
comparison
equal
deleted
inserted
replaced
3584:75268c1ea309 | 3585:113a9643e8bb |
---|---|
37 #include "Image.h" | 37 #include "Image.h" |
38 #include "ImageTraits.h" | 38 #include "ImageTraits.h" |
39 #include "PixelTraits.h" | 39 #include "PixelTraits.h" |
40 #include "../OrthancException.h" | 40 #include "../OrthancException.h" |
41 | 41 |
42 #ifdef __EMSCRIPTEN__ | |
43 /* | |
44 Avoid this error: | |
45 ----------------- | |
46 .../boost/math/special_functions/round.hpp:118:12: warning: implicit conversion from 'std::__2::numeric_limits<long long>::type' (aka 'long long') to 'float' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion] | |
47 .../mnt/c/osi/dev/orthanc/Core/Images/ImageProcessing.cpp:333:28: note: in instantiation of function template specialization 'boost::math::llround<float>' requested here | |
48 .../mnt/c/osi/dev/orthanc/Core/Images/ImageProcessing.cpp:1006:9: note: in instantiation of function template specialization 'Orthanc::MultiplyConstantInternal<unsigned char, true>' requested here | |
49 */ | |
50 #pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion" | |
51 #endif | |
52 | |
42 #include <boost/math/special_functions/round.hpp> | 53 #include <boost/math/special_functions/round.hpp> |
43 | 54 |
44 #include <cassert> | 55 #include <cassert> |
45 #include <string.h> | 56 #include <string.h> |
46 #include <limits> | 57 #include <limits> |
1872 | 1883 |
1873 std::vector<unsigned int> lookupX(targetWidth); | 1884 std::vector<unsigned int> lookupX(targetWidth); |
1874 | 1885 |
1875 for (unsigned int x = 0; x < targetWidth; x++) | 1886 for (unsigned int x = 0; x < targetWidth; x++) |
1876 { | 1887 { |
1877 int sourceX = std::floor((static_cast<float>(x) + 0.5f) * scaleX); | 1888 int sourceX = static_cast<int>(std::floor((static_cast<float>(x) + 0.5f) * scaleX)); |
1878 if (sourceX < 0) | 1889 if (sourceX < 0) |
1879 { | 1890 { |
1880 sourceX = 0; // Should never happen | 1891 sourceX = 0; // Should never happen |
1881 } | 1892 } |
1882 else if (sourceX >= static_cast<int>(sourceWidth)) | 1893 else if (sourceX >= static_cast<int>(sourceWidth)) |
1889 | 1900 |
1890 std::vector<unsigned int> lookupY(targetHeight); | 1901 std::vector<unsigned int> lookupY(targetHeight); |
1891 | 1902 |
1892 for (unsigned int y = 0; y < targetHeight; y++) | 1903 for (unsigned int y = 0; y < targetHeight; y++) |
1893 { | 1904 { |
1894 int sourceY = std::floor((static_cast<float>(y) + 0.5f) * scaleY); | 1905 int sourceY = static_cast<int>(std::floor((static_cast<float>(y) + 0.5f) * scaleY)); |
1895 if (sourceY < 0) | 1906 if (sourceY < 0) |
1896 { | 1907 { |
1897 sourceY = 0; // Should never happen | 1908 sourceY = 0; // Should never happen |
1898 } | 1909 } |
1899 else if (sourceY >= static_cast<int>(sourceHeight)) | 1910 else if (sourceY >= static_cast<int>(sourceHeight)) |
2171 } | 2182 } |
2172 } | 2183 } |
2173 } | 2184 } |
2174 | 2185 |
2175 // Deal with the right border | 2186 // Deal with the right border |
2176 for (unsigned int x = horizontalAnchor + width - horizontal.size() + 1; x < width; x++) | 2187 for (unsigned int x = static_cast<unsigned int>( |
2188 horizontalAnchor + width - horizontal.size() + 1); x < width; x++) | |
2177 { | 2189 { |
2178 for (unsigned int c = 0; c < ChannelsCount; c++, p++) | 2190 for (unsigned int c = 0; c < ChannelsCount; c++, p++) |
2179 { | 2191 { |
2180 *p = GetHorizontalConvolutionFloatSecure<RawPixel, ChannelsCount> | 2192 *p = GetHorizontalConvolutionFloatSecure<RawPixel, ChannelsCount> |
2181 (image, horizontal, horizontalAnchor, x, y, leftBorder[c], rightBorder[c], c); | 2193 (image, horizontal, horizontalAnchor, x, y, leftBorder[c], rightBorder[c], c); |
2203 { | 2215 { |
2204 rows[k] = reinterpret_cast<const float*>(tmp.GetConstRow(height - 1)); // Use bottom border | 2216 rows[k] = reinterpret_cast<const float*>(tmp.GetConstRow(height - 1)); // Use bottom border |
2205 } | 2217 } |
2206 else | 2218 else |
2207 { | 2219 { |
2208 rows[k] = reinterpret_cast<const float*>(tmp.GetConstRow(y + k - verticalAnchor)); | 2220 rows[k] = reinterpret_cast<const float*>(tmp.GetConstRow(static_cast<unsigned int>(y + k - verticalAnchor))); |
2209 } | 2221 } |
2210 } | 2222 } |
2211 | 2223 |
2212 RawPixel* p = reinterpret_cast<RawPixel*>(image.GetRow(y)); | 2224 RawPixel* p = reinterpret_cast<RawPixel*>(image.GetRow(y)); |
2213 | 2225 |