--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.utils.ui.gfx.clipboard.headers;\r
+\r
+import java.nio.ByteBuffer;\r
+import java.nio.ByteOrder;\r
+\r
+\r
+\r
+/**\r
+ * WIN32 API BITMAPFILEHEADER\r
+ * \r
+ * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_62uq.asp\r
+ * @author Marko Luukkainen\r
+ *\r
+ */\r
+public class BitmapFileHeader {\r
+ public short bfType;\r
+ public int bfSize;\r
+ public short bfReserved1;\r
+ public short bfReserved2;\r
+ public int bfOffBits;\r
+ public static final int sizeof = 14;\r
+ \r
+ /**\r
+ * Creates BITMAPFILEHEADER for bitmap that has\r
+ * BITMAPINFO.bmiColors field NULL / undefined \r
+ *\r
+ */\r
+ public BitmapFileHeader() {\r
+ bfType = 'B';\r
+ bfType <<= 8;\r
+ bfType |= (0xff & 'M');\r
+ bfSize = 0;\r
+ bfReserved1 = 0;\r
+ bfReserved2 = 0;\r
+ bfOffBits = sizeof + BitmapInfoHeader.sizeof;\r
+ \r
+ }\r
+ \r
+ public byte[] getBytes() {\r
+ byte [] array = new byte[sizeof];\r
+ ByteBuffer buffer = ByteBuffer.wrap(array);\r
+ buffer.order(ByteOrder.LITTLE_ENDIAN);\r
+ buffer.putShort(bfType);\r
+ buffer.putInt(bfSize);\r
+ buffer.putShort(bfReserved1);\r
+ buffer.putShort(bfReserved2);\r
+ buffer.putInt(bfOffBits);\r
+ return array;\r
+ }\r
+}\r