mkmojo / leptonica

Automatically exported from code.google.com/p/leptonica
0 stars 0 forks source link

Suggested BMP Change - bug in pixReadStreamBmp #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. try to load attached file

What is the expected output? What do you see instead?
Expect attached file to loads ok - instead get 'invalid image bytes' error

What version of the product are you using? On what operating system?
Latest: 1.66 - Windows 7

Please provide any additional information below.

Hi,

While using the leptonica library to process a bmp file (attached) I received 
the error 'invalid imagebytes' in 'pixReadStreamBmp' (in bmpio.c).

The associated bmp file had an 'imagebytes' value of 0 (which is possible when 
the compression type is 0 - see below)

Since you are already testing for compression == 0 earlier in the function, I 
would suggest changing:

    if (imagebytes != fileBpl * height)

to

    if (imagebytes != 0 && imagebytes != fileBpl * height)

Here are two references on the bmp file format which state the image size can 
be zero when compression is 0 (no compression):
http://en.wikipedia.org/wiki/BMP_file_format
http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html

Original issue reported on code.google.com by fizz_20...@yahoo.com on 29 Oct 2010 at 2:11

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you!  yet another legacy quirk for bmp.

This change will be distributed RSN (within 2 weeks) in 1.67.

Original comment by dan.bloo...@gmail.com on 29 Oct 2010 at 3:32

GoogleCodeExporter commented 9 years ago

Original comment by dan.bloo...@gmail.com on 12 Nov 2010 at 6:19