Bug 43161 - wrong construction of the DIB picture header
Summary: wrong construction of the DIB picture header
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-18 04:38 UTC by Michael Vilensky
Modified: 2010-05-30 02:58 UTC (History)
0 users



Attachments
Changes in org.apache.poi.hslf.blip.DIB to fix the issue (4.76 KB, patch)
2010-02-12 06:37 UTC, hacho
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Vilensky 2007-08-18 04:38:48 UTC
hey!

imho, there are some incorrectness in the construction of the DIB header:

" //Specifies the size, in bytes, of the bitmap file.
        LittleEndian.putInt(header, 2, data.length); //DIB length including 
the header"

well, if it specifies the size of the file including the header then it should 
be something like:
LittleEndian.putInt(header, 2, data.length + header.lenght); 

"//the offset, in bytes, from the header to the bitmap bits (looks like it is 
always 2)
        LittleEndian.putInt(header, 10, 2);"

the size of the header is 14 bytes, so this field should be at least 14 (this 
is the basic header, almost in all DIB's there are another header following 
this one, but I don't know should it be here or not...) so if you use only 
this header, this fiels should be exactly 14.

hope this info will be useful.

mike.
Comment 1 hacho 2010-02-12 06:34:30 UTC
I am experiencing the same issue with version 3.6 (poi-scratchpad-3.6-20091214.jar).

Attaching here a modified org.apache.poi.hslf.blip.DIB code
Basically the current function getData() adds a proper header. I made a small modification to produce the correct header values and renamed the function to addBMPHeader(). I then created a wrapper so the original getData() is intact.

I exposed addBMPHeader() as a separate public static method, because there are other cases where you need to append a header to the raw DIB information stored in the OLE2 stream. For example in Excel tables.

I will attach the test case for this situation.
Comment 2 hacho 2010-02-12 06:37:46 UTC
Created attachment 24974 [details]
Changes in org.apache.poi.hslf.blip.DIB to fix the issue
Comment 3 Yegor Kozlov 2010-05-30 02:58:06 UTC
Patch applied in r949483.

Thanks,
Yegor