poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r949483 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java test-data/slideshow/clock.dib
Date Sun, 30 May 2010 06:56:32 GMT
Author: yegor
Date: Sun May 30 06:56:32 2010
New Revision: 949483

URL: http://svn.apache.org/viewvc?rev=949483&view=rev
Log:
fixed construction of the DIB picture header, see Bugzilla 43161

Added:
    poi/trunk/test-data/slideshow/clock.dib   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=949483&r1=949482&r2=949483&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sun May 30 06:56:32 2010
@@ -34,6 +34,8 @@
 
     <changes>
         <release version="3.7-SNAPSHOT" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">43161 - fixed construction of the
DIB picture header</action>
+           <action dev="POI-DEVELOPERS" type="add">49311 - initial support for reading
AES-encrypted/write-protected OOXML files</action>
            <action dev="POI-DEVELOPERS" type="fix">48718 - Make the creation of multiple,
un-modified fonts in a row in XSSF match the old HSSF behaviour</action>
            <action dev="POI-DEVELOPERS" type="fix">44916 - Allow access to the HSSFPatriarch
from HSSFSheet once created</action>
            <action dev="POI-DEVELOPERS" type="add">48779 - Allow you to get straight
from a CellStyle to a Color, irrespective of if the Color is indexed or inline-defined</action>
@@ -93,7 +95,6 @@
            <action dev="POI-DEVELOPERS" type="fix">48339 - fixed ExternalNameRecord
to properly distinguish DDE data from OLE data items </action>
            <action dev="POI-DEVELOPERS" type="fix">47920 - allow editing workbooks
embedded into PowerPoint files</action>
            <action dev="POI-DEVELOPERS" type="add">48343 - added implementation of
SUBTOTAL function</action>
-           <action dev="POI-DEVELOPERS" type="add">49311 - initial support for reading
AES-encrypted/write-protected OOXML files</action>
         </release>
         <release version="3.6" date="2009-12-14">
            <action dev="POI-DEVELOPERS" type="fix">48332 - fixed XSSFSheet autoSizeColumn()
to tolerate empty RichTextString</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java?rev=949483&r1=949482&r2=949483&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java Sun May 30 06:56:32 2010
@@ -49,23 +49,32 @@ public final class DIB extends Bitmap {
     public int getSignature(){
         return 0x7A80;
     }
-
+    
     public byte[] getData(){
-        byte[] data = super.getData();
+        return addBMPHeader ( super.getData() );
+    }
 
+    public static byte[] addBMPHeader(byte[] data){
         // bitmap file-header, corresponds to a
         // Windows  BITMAPFILEHEADER structure
         // (For more information, consult the Windows API Programmer's reference )
         byte[] header = new byte[HEADER_SIZE];
         //Specifies the file type. It must be set to the signature word BM (0x4D42) to indicate
bitmap.
         LittleEndian.putInt(header, 0, 0x4D42);
-        //Specifies the size, in bytes, of the bitmap file.
-        LittleEndian.putInt(header, 2, data.length); //DIB length including the header
-        //Reserved; set to zero
-        LittleEndian.putInt(header, 6, 0);
-        //the offset, in bytes, from the header to the bitmap bits (looks like it is always
2)
-        LittleEndian.putInt(header, 10, 2);
 
+        // read the size of the image and calculate the overall file size
+        // and the offset where the bitmap starts
+        int imageSize = LittleEndian.getInt(data, 0x22 - HEADER_SIZE);
+        int fileSize = data.length + HEADER_SIZE;
+        int offset = fileSize - imageSize;
+        
+		// specifies the size, in bytes, of the bitmap file - must add the length of the header
+        LittleEndian.putInt(header, 2, fileSize); 
+        // Reserved; set to zero
+        LittleEndian.putInt(header, 6, 0);
+        // the offset, i.e. starting address, of the byte where the bitmap data can be found
+        LittleEndian.putInt(header, 10, offset);
+        
         //DIB data is the header + dib bytes
         byte[] dib = new byte[header.length + data.length];
         System.arraycopy(header, 0, dib, 0, header.length);

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java?rev=949483&r1=949482&r2=949483&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java Sun
May 30 06:56:32 2010
@@ -252,7 +252,7 @@ public final class TestPictures extends 
         SlideShow ppt = new SlideShow();
 
         Slide slide = ppt.createSlide();
-        byte[] src_bytes = slTests.readFile("sci_cec.dib");
+        byte[] src_bytes = slTests.readFile("clock.dib");
         int idx = ppt.addPicture(src_bytes, Picture.DIB);
         Picture pict = new Picture(idx);
         assertEquals(idx, pict.getPictureIndex());

Added: poi/trunk/test-data/slideshow/clock.dib
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/clock.dib?rev=949483&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/clock.dib
------------------------------------------------------------------------------
    svn:executable = *

Propchange: poi/trunk/test-data/slideshow/clock.dib
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message