diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index 8797b6f4a..e9344af07 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -333,9 +333,9 @@ image_data_any tiff_reader::read_any_gray(unsigned x0, unsigned y0, unsigned image_data_type data(width, height); std::size_t block_size = rows_per_strip_ > 0 ? rows_per_strip_ : tile_height_ ; std::ptrdiff_t start_y = y0 - y0 % block_size; - std::ptrdiff_t end_y = std::min(y0 + height, (unsigned)height_); + std::ptrdiff_t end_y = std::min(y0 + height, static_cast(height_)); std::ptrdiff_t start_x = x0; - std::ptrdiff_t end_x = std::min(x0 + width, (unsigned)width_); + std::ptrdiff_t end_x = std::min(x0 + width, static_cast(width_)); std::size_t element_size = sizeof(pixel_type); std::size_t size_to_allocate = (TIFFScanlineSize(tif) + element_size - 1)/element_size; std::cerr << "size_to_allocate=" << size_to_allocate << std::endl; @@ -415,9 +415,9 @@ image_data_any tiff_reader::read(unsigned x0, unsigned y0, unsigned width, un std::size_t size_to_allocate = (TIFFScanlineSize(tif) + element_size - 1)/element_size; const std::unique_ptr scanline(new detail::rgb8[size_to_allocate]); std::ptrdiff_t start_y = y0 - y0 % rows_per_strip_; - std::ptrdiff_t end_y = std::min(y0 + height, (unsigned)height_); + std::ptrdiff_t end_y = std::min(y0 + height, static_cast(height_)); std::ptrdiff_t start_x = x0; - std::ptrdiff_t end_x = std::min(x0 + width, (unsigned)width_); + std::ptrdiff_t end_x = std::min(x0 + width, static_cast(width_)); for (std::size_t y = start_y; y < end_y; ++y) { if (-1 != TIFFReadScanline(tif, scanline.get(), y)) @@ -498,8 +498,8 @@ void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_rgba8& image) for (int y=start_y;y(y)) - y; + ty1 = std::min(height+y0,static_cast(y+tile_height_)) - y; int n0=tile_height_-ty1; int n1=tile_height_-ty0-1; @@ -513,12 +513,12 @@ void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_rgba8& image) break; } - tx0=std::max(x0,(unsigned)x); - tx1=std::min(width+x0,(unsigned)(x+tile_width_)); + tx0=std::max(x0,static_cast(x)); + tx1=std::min(width+x0,static_cast(x+tile_width_)); row=y+ty0-y0; for (int n=n1;n>=n0;--n) { - image.setRow(row,tx0-x0,tx1-x0,(const unsigned*)&buf[n*tile_width_+tx0-x]); + image.setRow(row,tx0-x0,tx1-x0,static_cast(&buf[n*tile_width_+tx0-x])); ++row; } } @@ -538,11 +538,11 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_rgba8& ima unsigned start_y=(y0/rows_per_strip_)*rows_per_strip_; unsigned end_y=((y0+height)/rows_per_strip_+1)*rows_per_strip_; - bool laststrip=((unsigned)end_y > height_)?true:false; + bool laststrip=(static_cast(end_y) > height_)?true:false; int row,tx0,tx1,ty0,ty1; tx0=x0; - tx1=std::min(width+x0,(unsigned)width_); + tx1=std::min(width+x0,static_cast(width_)); for (unsigned y=start_y; y < end_y; y+=rows_per_strip_) { @@ -560,7 +560,7 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_rgba8& ima int n1=laststrip ? (ty1-ty0-1):(rows_per_strip_-ty0-1); for (int n=n1;n>=n0;--n) { - image.setRow(row,tx0-x0,tx1-x0,(const unsigned*)&buf[n*width_+tx0]); + image.setRow(row,tx0-x0,tx1-x0,static_cast(&buf[n*width_+tx0])); ++row; } }