1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.utils.ui.gfx.clipboard.headers;
\r
14 import java.nio.ByteBuffer;
\r
15 import java.nio.ByteOrder;
\r
20 * WIN32 API BITMAPFILEHEADER
\r
22 * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_62uq.asp
\r
23 * @author Marko Luukkainen
\r
26 public class BitmapFileHeader {
\r
27 public short bfType;
\r
29 public short bfReserved1;
\r
30 public short bfReserved2;
\r
31 public int bfOffBits;
\r
32 public static final int sizeof = 14;
\r
35 * Creates BITMAPFILEHEADER for bitmap that has
\r
36 * BITMAPINFO.bmiColors field NULL / undefined
\r
39 public BitmapFileHeader() {
\r
42 bfType |= (0xff & 'M');
\r
46 bfOffBits = sizeof + BitmapInfoHeader.sizeof;
\r
50 public byte[] getBytes() {
\r
51 byte [] array = new byte[sizeof];
\r
52 ByteBuffer buffer = ByteBuffer.wrap(array);
\r
53 buffer.order(ByteOrder.LITTLE_ENDIAN);
\r
54 buffer.putShort(bfType);
\r
55 buffer.putInt(bfSize);
\r
56 buffer.putShort(bfReserved1);
\r
57 buffer.putShort(bfReserved2);
\r
58 buffer.putInt(bfOffBits);
\r