+++ /dev/null
-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
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