[ 
https://issues.apache.org/jira/browse/IMAGING-162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14330319#comment-14330319
 ] 

Michael Groß edited comment on IMAGING-162 at 2/21/15 4:03 PM:
---------------------------------------------------------------

I created the PRs on github for this and also for the other patches I that I 
propose.

This proposed patch works yet (as date of writing) only for BMPs which are not 
RLE encoded. I didn't touch the code for RLE -encoded- compressed BMPs yet, nor 
i did execute some specific tests for this format. (But I am working on it).

A word about the test cases: All existing tests seems to executed in a big loop 
over all available test images. Each test class is executed for the images wich 
fitting type, i.e. BMP test clases for BMPs. This is good to see if a 
particular image raises some exceptions in the code, but it does not allow to 
create specific tests i.e. asserting if the pixels of a BMP with negative 
height are read as expected or if a broken image file throws a certain 
exception.

There fore I added the package 
*org.apache.commons.imaging.formats.bmp.specific* to have such tests for BMPs 
here. They aren't executed by the "big loop" described before thus they are 
independed from what images are in *src/test/data/images*. Accordingly I added  
*src/test/data/specificTests* for image examples which are not used in the "big 
loop".

So I would propose that when we want to fix an issue like this we first add 
example images to *src/test/data/specificTests* and add tests which reproduces 
the problem to a package called 
*org.apache.commons.imaging.formats.<FORMAT>.specific*.


was (Author: mgmechanics):
I created the PRs on github for this and also for the other patches I that I 
propose.

This proposed patch works yet (as date of writing) only for BMPs which are not 
RLE encoded. I didn't touch the code for RLE encoded BMPs yet, nor i did 
execute some specific tests for this format. (But I am working on it).

A word about the test cases: All existing tests seems to executed in a big loop 
over all available test images. Each test class is executed for the images wich 
fitting type, i.e. BMP test clases for BMPs. This is good to see if a 
particular image raises some exceptions in the code, but it does not allow to 
create specific tests i.e. asserting if the pixels of a BMP with negative 
height are read as expected or if a broken image file throws a certain 
exception.

There fore I added the package 
*org.apache.commons.imaging.formats.bmp.specific* to have such tests for BMPs 
here. They aren't executed by the "big loop" described before thus they are 
independed from what images are in *src/test/data/images*. Accordingly I added  
*src/test/data/specificTests* for image examples which are not used in the "big 
loop".

So I would propose that when we want to fix an issue like this we first add 
example images to *src/test/data/specificTests* and add tests which reproduces 
the problem to a package called 
*org.apache.commons.imaging.formats.<FORMAT>.specific*.

> BMP files with negative bitmap height are not supported
> -------------------------------------------------------
>
>                 Key: IMAGING-162
>                 URL: https://issues.apache.org/jira/browse/IMAGING-162
>             Project: Commons Imaging
>          Issue Type: Bug
>          Components: Format: BMP
>    Affects Versions: 1.0
>            Reporter: Myroslav Golub
>              Labels: github
>             Fix For: Review Patch
>
>         Attachments: monochrome-negative-height.bmp
>
>
> The BMP format allows for negative values of the height field in the header. 
> This means that the image lines are stored top-down, not bottom-up as usual 
> (i. e. the first pixel in the pixel array would be in the top left corner of 
> the image, not in the bottom left as usual). However, when a negative-height 
> bitmap is passed, the BmpImageParser attempts to create an array of negative 
> length, and a NegativeArraySizeException ensues.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to