Skip to content

Commit 72cca56

Browse files
committed
Minor cleanup.
1 parent 22fb744 commit 72cca56

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Source/Plugins/PluginTIFF.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "../Metadata/FreeImageTag.h"
5050
#include "FreeImageIO.h"
5151
#include "PSDParser.h"
52+
#include "yato/types.h"
5253

5354
// --------------------------------------------------------------------------
5455
// GeoTIFF profile (see XTIFF.cpp)
@@ -1314,7 +1315,7 @@ template <typename DT> static void DecodeMonoStrip(const uint8_t *buf, const tms
13141315
for (uint32_t l{}; l < strips; ++l) {
13151316
uint8_t poffset{ offset };
13161317
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);
13181319
uint32_t t{}, i{};
13191320
uint16_t stored_bits{};
13201321
while (i < dst_line) {
@@ -1342,8 +1343,8 @@ template <typename DT, typename DS = uint8_t> static void DecodeStrip(const uint
13421343
const uint32_t bits_mask = (static_cast<uint32_t>(1) << bitspersample) - 1;
13431344

13441345
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;
13471348
uint32_t t{}, i{};
13481349
uint16_t stored_bits{};
13491350
while (i < dst_line) {
@@ -1548,7 +1549,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
15481549
// ---------------------------------------------------------------------------------
15491550

15501551
// 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)));
15521553
if (!dib) {
15531554
throw FI_MSG_ERROR_DIB_MEMORY;
15541555
}
@@ -2258,11 +2259,11 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
22582259

22592260
half half_value;
22602261

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);
22642265

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) {
22662267
half_value.setBits(src_pixel[x]);
22672268
dst_pixel[x] = half_value;
22682269
}

0 commit comments

Comments
 (0)