Use size_t to avoid possible numeric overflow for the very largest images.

pull/2946/head
Davis King 5 months ago
parent 792b744402
commit 73c990dd18

@ -182,7 +182,7 @@ namespace dlib
data.resize(height_*width_*output_components_);
// setup pointers to each row
for (unsigned long i = 0; i < rows.size(); ++i)
for (size_t i = 0; i < rows.size(); ++i)
rows[i] = &data[i*width_*output_components_];
// read the data into the buffer

@ -43,10 +43,10 @@ namespace dlib
#endif
image_view<T> t(t_);
t.set_size( height_, width_ );
for ( unsigned n = 0; n < height_;n++ )
for (size_t n = 0; n < height_;n++ )
{
const unsigned char* v = get_row( n );
for ( unsigned m = 0; m < width_;m++ )
for (size_t m = 0; m < width_;m++ )
{
if ( is_gray() )
{
@ -74,16 +74,16 @@ namespace dlib
}
private:
const unsigned char* get_row( unsigned long i ) const
const unsigned char* get_row(size_t i) const
{
return &data[i*width_*output_components_];
}
FILE * check_file(const char* filename );
void read_image( FILE *file, const unsigned char* imgbuffer, size_t imgbuffersize );
unsigned long height_;
unsigned long width_;
unsigned long output_components_;
size_t long height_;
size_t long width_;
size_t long output_components_;
std::vector<unsigned char> data;
};

Loading…
Cancel
Save