]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/clipboard/headers/BitmapFileHeader.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / gfx / clipboard / headers / BitmapFileHeader.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.ui.gfx.clipboard.headers;
13
14 import java.nio.ByteBuffer;
15 import java.nio.ByteOrder;
16
17
18
19 /**
20  * WIN32 API BITMAPFILEHEADER
21  * 
22  * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_62uq.asp
23  * @author Marko Luukkainen
24  *
25  */
26 public class BitmapFileHeader {
27     public short bfType;
28     public int bfSize;
29     public short bfReserved1;
30     public short bfReserved2;
31     public int bfOffBits;
32     public static final int sizeof = 14;
33     
34     /**
35      * Creates BITMAPFILEHEADER for bitmap that has
36      * BITMAPINFO.bmiColors field NULL / undefined 
37      *
38      */
39     public BitmapFileHeader() {
40         bfType = 'B';
41         bfType <<= 8;
42         bfType |= (0xff & 'M');
43         bfSize = 0;
44         bfReserved1 = 0;
45         bfReserved2 = 0;
46         bfOffBits = sizeof + BitmapInfoHeader.sizeof;
47     
48     }
49     
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);
59         return array;
60     }
61 }