]> source.dussan.org Git - poi.git/commitdiff
DIBBITBLT Record
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 9 Feb 2014 23:06:22 +0000 (23:06 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 9 Feb 2014 23:06:22 +0000 (23:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/wmf_render@1566465 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwmf/record/WmfBitmap.java [deleted file]
src/scratchpad/src/org/apache/poi/hwmf/record/WmfFill.java
src/scratchpad/src/org/apache/poi/hwmf/record/WmfRecordType.java

diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/WmfBitmap.java b/src/scratchpad/src/org/apache/poi/hwmf/record/WmfBitmap.java
deleted file mode 100644 (file)
index 480b3d3..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.apache.poi.hwmf.record;\r
-\r
-import java.io.IOException;\r
-\r
-import org.apache.poi.util.LittleEndianConsts;\r
-import org.apache.poi.util.LittleEndianInputStream;\r
-\r
-public class WmfBitmap {\r
-\r
-    /**\r
-     * The META_SETDIBTODEV record sets a block of pixels in the playback device context\r
-     * using deviceindependent color data.\r
-     * The source of the color data is a DIB\r
-     */\r
-    public static class WmfSetDibToDev implements WmfRecord {\r
-\r
-        /**\r
-         * A 16-bit unsigned integer that defines whether the Colors field of the\r
-         * DIB contains explicit RGB values or indexes into a palette.\r
-         * This MUST be one of the values in the ColorUsage Enumeration:\r
-         * DIB_RGB_COLORS = 0x0000,\r
-         * DIB_PAL_COLORS = 0x0001,\r
-         * DIB_PAL_INDICES = 0x0002\r
-         */\r
-        int colorUsage;  \r
-        /**\r
-         * A 16-bit unsigned integer that defines the number of scan lines in the source.\r
-         */\r
-        int scanCount;\r
-        /**\r
-         * A 16-bit unsigned integer that defines the starting scan line in the source.\r
-         */\r
-        int startScan;  \r
-        /**\r
-         * A 16-bit unsigned integer that defines the y-coordinate, in logical units, of the\r
-         * source rectangle.\r
-         */\r
-        int yDib;  \r
-        /**\r
-         * A 16-bit unsigned integer that defines the x-coordinate, in logical units, of the\r
-         * source rectangle.\r
-         */\r
-        int xDib;  \r
-        /**\r
-         * A 16-bit unsigned integer that defines the height, in logical units, of the\r
-         * source and destination rectangles.\r
-         */\r
-        int height;\r
-        /**\r
-         * A 16-bit unsigned integer that defines the width, in logical units, of the\r
-         * source and destination rectangles.\r
-         */\r
-        int width;\r
-        /**\r
-         * A 16-bit unsigned integer that defines the y-coordinate, in logical units, of the\r
-         * upper-left corner of the destination rectangle.\r
-         */\r
-        int yDest;\r
-        /**\r
-         * A 16-bit unsigned integer that defines the x-coordinate, in logical units, of the\r
-         * upper-left corner of the destination rectangle.\r
-         */\r
-        int xDest;\r
-        /**\r
-         * A variable-sized DeviceIndependentBitmap Object that is the source of the color data.\r
-         */\r
-        WmfBitmapDib dib;        \r
-        \r
-        \r
-        public WmfRecordType getRecordType() {\r
-            return WmfRecordType.setDibToDev;\r
-        }\r
-        \r
-        public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {\r
-            colorUsage = leis.readUShort();\r
-            scanCount = leis.readUShort();\r
-            startScan = leis.readUShort();\r
-            yDib = leis.readUShort();\r
-            xDib = leis.readUShort();\r
-            height = leis.readUShort();\r
-            width = leis.readUShort();\r
-            yDest = leis.readUShort();\r
-            xDest = leis.readUShort();\r
-            \r
-            int size = 9*LittleEndianConsts.SHORT_SIZE;\r
-            dib = new WmfBitmapDib();\r
-            size += dib.init(leis);\r
-            \r
-            return size;\r
-        }        \r
-    }\r
-}\r
index 011304d593de1b2a05e7dc6feed8ff59f3f5a62c..44d504aac95cb06ef6b654a4594109828abaa46e 100644 (file)
@@ -421,4 +421,170 @@ public class WmfFill {
             return size;\r
         }\r
     }\r
+\r
+\r
+    /**\r
+     * The META_SETDIBTODEV record sets a block of pixels in the playback device context\r
+     * using deviceindependent color data.\r
+     * The source of the color data is a DIB\r
+     */\r
+    public static class WmfSetDibToDev implements WmfRecord {\r
+\r
+        /**\r
+         * A 16-bit unsigned integer that defines whether the Colors field of the\r
+         * DIB contains explicit RGB values or indexes into a palette.\r
+         * This MUST be one of the values in the ColorUsage Enumeration:\r
+         * DIB_RGB_COLORS = 0x0000,\r
+         * DIB_PAL_COLORS = 0x0001,\r
+         * DIB_PAL_INDICES = 0x0002\r
+         */\r
+        int colorUsage;  \r
+        /**\r
+         * A 16-bit unsigned integer that defines the number of scan lines in the source.\r
+         */\r
+        int scanCount;\r
+        /**\r
+         * A 16-bit unsigned integer that defines the starting scan line in the source.\r
+         */\r
+        int startScan;  \r
+        /**\r
+         * A 16-bit unsigned integer that defines the y-coordinate, in logical units, of the\r
+         * source rectangle.\r
+         */\r
+        int yDib;  \r
+        /**\r
+         * A 16-bit unsigned integer that defines the x-coordinate, in logical units, of the\r
+         * source rectangle.\r
+         */\r
+        int xDib;  \r
+        /**\r
+         * A 16-bit unsigned integer that defines the height, in logical units, of the\r
+         * source and destination rectangles.\r
+         */\r
+        int height;\r
+        /**\r
+         * A 16-bit unsigned integer that defines the width, in logical units, of the\r
+         * source and destination rectangles.\r
+         */\r
+        int width;\r
+        /**\r
+         * A 16-bit unsigned integer that defines the y-coordinate, in logical units, of the\r
+         * upper-left corner of the destination rectangle.\r
+         */\r
+        int yDest;\r
+        /**\r
+         * A 16-bit unsigned integer that defines the x-coordinate, in logical units, of the\r
+         * upper-left corner of the destination rectangle.\r
+         */\r
+        int xDest;\r
+        /**\r
+         * A variable-sized DeviceIndependentBitmap Object that is the source of the color data.\r
+         */\r
+        WmfBitmapDib dib;        \r
+        \r
+        \r
+        public WmfRecordType getRecordType() {\r
+            return WmfRecordType.setDibToDev;\r
+        }\r
+        \r
+        public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {\r
+            colorUsage = leis.readUShort();\r
+            scanCount = leis.readUShort();\r
+            startScan = leis.readUShort();\r
+            yDib = leis.readUShort();\r
+            xDib = leis.readUShort();\r
+            height = leis.readUShort();\r
+            width = leis.readUShort();\r
+            yDest = leis.readUShort();\r
+            xDest = leis.readUShort();\r
+            \r
+            int size = 9*LittleEndianConsts.SHORT_SIZE;\r
+            dib = new WmfBitmapDib();\r
+            size += dib.init(leis);\r
+            \r
+            return size;\r
+        }        \r
+    }\r
+\r
+\r
+    public static class WmfDibBitBlt implements WmfRecord {\r
+\r
+        /**\r
+         * A 32-bit unsigned integer that defines how the source pixels, the current brush\r
+         * in the playback device context, and the destination pixels are to be combined to form the\r
+         * new image. This code MUST be one of the values in the Ternary Raster Operation Enumeration.\r
+         */\r
+        WmfTernaryRasterOp rasterOperation;  \r
+        /**\r
+         * A 16-bit signed integer that defines the y-coordinate, in logical units, of the source rectangle.\r
+         */\r
+        int ySrc;\r
+        /**\r
+         * A 16-bit signed integer that defines the x-coordinate, in logical units, of the source rectangle.\r
+         */\r
+        int xSrc;\r
+        /**\r
+         * A 16-bit signed integer that defines the height, in logical units, of the source and \r
+         * destination rectangles.\r
+         */\r
+        int height;\r
+        /**\r
+         * A 16-bit signed integer that defines the width, in logical units, of the source and destination\r
+         * rectangles.\r
+         */\r
+        int width;\r
+        /**\r
+         * A 16-bit signed integer that defines the y-coordinate, in logical units, of the upper-left\r
+         * corner of the destination rectangle.\r
+         */\r
+        int yDest;\r
+        /**\r
+         * A 16-bit signed integer that defines the x-coordinate, in logical units, of the upper-left \r
+         * corner of the destination rectangle.\r
+         */\r
+        int xDest;\r
+        \r
+        /**\r
+         * A variable-sized DeviceIndependentBitmap Object that defines image content.\r
+         * This object MUST be specified, even if the raster operation does not require a source.\r
+         */\r
+        WmfBitmapDib target;\r
+        \r
+        \r
+        public WmfRecordType getRecordType() {\r
+            return WmfRecordType.dibBitBlt;\r
+        }\r
+        \r
+        public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {\r
+            boolean hasBitmap = (recordSize > ((recordFunction >> 8) + 3));\r
+\r
+            int size = 0;\r
+            int rasterOpIndex = leis.readUShort();\r
+            int rasterOpCode = leis.readUShort();\r
+            \r
+            rasterOperation = WmfTernaryRasterOp.fromOpIndex(rasterOpIndex);\r
+            assert(rasterOpCode == rasterOperation.opCode);\r
+\r
+            ySrc = leis.readShort();\r
+            xSrc = leis.readShort();\r
+            size = 4*LittleEndianConsts.SHORT_SIZE;\r
+            if (!hasBitmap) {\r
+                @SuppressWarnings("unused")\r
+                int reserved = leis.readShort();\r
+                size += LittleEndianConsts.SHORT_SIZE;\r
+            }\r
+            height = leis.readShort();\r
+            width = leis.readShort();\r
+            yDest = leis.readShort();\r
+            xDest = leis.readShort();\r
+            \r
+            size += 4*LittleEndianConsts.SHORT_SIZE;\r
+            if (hasBitmap) {\r
+                target = new WmfBitmapDib();\r
+                size += target.init(leis);\r
+            }\r
+            \r
+            return size;\r
+        }\r
+    }\r
 }\r
index 1ae118db713e57ace1c5eff6b146b1e975ff5bd9..d97b36260d29b665918bd38b8e02405e106109f9 100644 (file)
@@ -60,8 +60,8 @@ public enum WmfRecordType {
     chord(0x0830, WmfDraw.WmfChord.class),\r
     bitBlt(0x0922, WmfFill.WmfBitBlt.class),\r
     extTextOut(0x0a32, WmfText.WmfExtTextOut.class),\r
-    setDibToDev(0x0d33, WmfBitmap.WmfSetDibToDev.class),\r
-    dibBitBlt(0x0940, null),\r
+    setDibToDev(0x0d33, WmfFill.WmfSetDibToDev.class),\r
+    dibBitBlt(0x0940, WmfFill.WmfDibBitBlt.class),\r
     dibStretchBlt(0x0b41, null),\r
     stretchDib(0x0f43, null),\r
     deleteObject(0x01f0, null),\r