Fix crop_area_byte_length calculation in crop_image and add tests

This commit is contained in:
n0max 2017-03-13 19:26:12 +01:00
parent e34aac03ff
commit 6f470e497f
8 changed files with 185 additions and 1 deletions

View file

@ -746,7 +746,7 @@ fn crop_image(image_data: Vec<u8>,
// (consecutive elements in a pixel row of the image are contiguous in memory)
let stride = image_size.width * 4;
let image_bytes_length = image_size.height * image_size.width * 4;
let crop_area_bytes_length = crop_rect.size.height * crop_rect.size.height * 4;
let crop_area_bytes_length = crop_rect.size.height * crop_rect.size.width * 4;
// If the image size is less or equal than the crop area we do nothing
if image_bytes_length <= crop_area_bytes_length {
return image_data;