Fixed the load_bmp function with respect to another weird BMP format I found.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403025
This commit is contained in:
Davis King 2009-05-02 16:15:46 +00:00
parent 60f3dda36c
commit 1e3fb451f3
1 changed files with 15 additions and 0 deletions

View File

@ -12,6 +12,7 @@
#include "../entropy_decoder_model.h"
#include "../entropy_decoder.h"
#include "../uintn.h"
#include "../image_transforms/assign_image.h"
#include <algorithm>
namespace dlib
@ -412,7 +413,13 @@ namespace dlib
// This is the escape code for a run of uncompressed bytes
if (row < 0 || col + command > image.nc())
{
// If this is just some padding bytes at the end then ignore them
if (row >= 0 && col + count <= image.nc() + padding)
continue;
throw image_load_error("bmp load error 21.2: file data corrupt");
}
// put the bytes into the image
for (unsigned int i = 0; i < command; ++i)
@ -439,12 +446,20 @@ namespace dlib
throw image_load_error("bmp load error 21.4: file too short");
}
}
continue;
}
rgb_pixel p;
if (row < 0 || col + count > image.nc())
{
// If this is just some padding bytes at the end then ignore them
if (row >= 0 && col + count <= image.nc() + padding)
continue;
throw image_load_error("bmp load error 21.5: file data corrupt");
}
// put the bytes into the image
for (unsigned int i = 0; i < count; ++i)