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