|
49 | 49 | #include "../Metadata/FreeImageTag.h" |
50 | 50 | #include "FreeImageIO.h" |
51 | 51 | #include "PSDParser.h" |
| 52 | +#include "yato/types.h" |
52 | 53 |
|
53 | 54 | // -------------------------------------------------------------------------- |
54 | 55 | // GeoTIFF profile (see XTIFF.cpp) |
@@ -1314,7 +1315,7 @@ template <typename DT> static void DecodeMonoStrip(const uint8_t *buf, const tms |
1314 | 1315 | for (uint32_t l{}; l < strips; ++l) { |
1315 | 1316 | uint8_t poffset{ offset }; |
1316 | 1317 | const uint8_t *src_pixel = buf; |
1317 | | - auto *dst_pixel = reinterpret_cast<DT *>(dst_line_begin); |
| 1318 | + auto *dst_pixel = yato::pointer_cast<DT*>(dst_line_begin); |
1318 | 1319 | uint32_t t{}, i{}; |
1319 | 1320 | uint16_t stored_bits{}; |
1320 | 1321 | while (i < dst_line) { |
@@ -1342,8 +1343,8 @@ template <typename DT, typename DS = uint8_t> static void DecodeStrip(const uint |
1342 | 1343 | const uint32_t bits_mask = (static_cast<uint32_t>(1) << bitspersample) - 1; |
1343 | 1344 |
|
1344 | 1345 | for (uint32_t l{}; l < strips; ++l) { |
1345 | | - const auto* src_pixel = reinterpret_cast<const DS*>(buf); |
1346 | | - auto *dst_pixel = reinterpret_cast<DT*>(dst_line_begin) + sample; |
| 1346 | + const auto* src_pixel = yato::pointer_cast<const DS*>(buf); |
| 1347 | + auto *dst_pixel = yato::pointer_cast<DT*>(dst_line_begin) + sample; |
1347 | 1348 | uint32_t t{}, i{}; |
1348 | 1349 | uint16_t stored_bits{}; |
1349 | 1350 | while (i < dst_line) { |
@@ -1548,7 +1549,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { |
1548 | 1549 | // --------------------------------------------------------------------------------- |
1549 | 1550 |
|
1550 | 1551 | // create a new 8-bit DIB |
1551 | | - dib.reset(CreateImageType(header_only, image_type, width, height, bitspersample, MIN<uint16_t>(2, samplesperpixel))); |
| 1552 | + dib.reset(CreateImageType(header_only, image_type, width, height, bitspersample, std::min<uint16_t>(2, samplesperpixel))); |
1552 | 1553 | if (!dib) { |
1553 | 1554 | throw FI_MSG_ERROR_DIB_MEMORY; |
1554 | 1555 | } |
@@ -2258,11 +2259,11 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) { |
2258 | 2259 |
|
2259 | 2260 | half half_value; |
2260 | 2261 |
|
2261 | | - for (uint32_t l = 0; l < nrow; l++) { |
2262 | | - uint16_t *src_pixel = (uint16_t*)(buf.get() + l * src_line); |
2263 | | - float *dst_pixel = (float*)bits; |
| 2262 | + for (uint32_t l = 0; l < nrow; ++l) { |
| 2263 | + const uint16_t *src_pixel = yato::pointer_cast<uint16_t*>(buf.get() + l * src_line); |
| 2264 | + float *dst_pixel = yato::pointer_cast<float*>(bits); |
2264 | 2265 |
|
2265 | | - for (tmsize_t x = 0; x < (tmsize_t)(src_line / sizeof(uint16_t)); x++) { |
| 2266 | + for (tmsize_t x = 0; x < (tmsize_t)(src_line / sizeof(uint16_t)); ++x) { |
2266 | 2267 | half_value.setBits(src_pixel[x]); |
2267 | 2268 | dst_pixel[x] = half_value; |
2268 | 2269 | } |
|
0 commit comments