]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/clipboard/headers/BitmapInfoHeader.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / gfx / clipboard / headers / BitmapInfoHeader.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  * WIN32 API BITMAPINFOHEADER
20  * 
21  * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_1rw2.asp
22  * @see org.eclipse.swt.internal.win32.BITMAPINFOHEADER
23  * @author Marko Luukkainen
24  *
25  */
26 @SuppressWarnings("restriction")
27 public class BitmapInfoHeader {
28     public int biSize;
29     public int biWidth;
30     public int biHeight;
31     public short biPlanes;
32     public short biBitCount;
33     public int biCompression;
34     public int biSizeImage;
35     public int biXPelsPerMeter;
36     public int biYPelsPerMeter;
37     public int biClrUsed;
38     public int biClrImportant;
39     public static final int sizeof = 40;   
40     
41     public byte[] getBytes() {
42         byte [] array = new byte[sizeof];
43         ByteBuffer buffer = ByteBuffer.wrap(array);
44         buffer.order(ByteOrder.LITTLE_ENDIAN);
45         buffer.putInt(biSize);
46         buffer.putInt(biWidth);
47         buffer.putInt(biHeight);
48         buffer.putShort(biPlanes);
49         buffer.putShort(biBitCount);
50         buffer.putInt(biCompression);
51         buffer.putInt(biSizeImage);
52         buffer.putInt(biXPelsPerMeter);
53         buffer.putInt(biYPelsPerMeter);
54         buffer.putInt(biClrUsed);
55         buffer.putInt(biClrImportant); 
56         return array;
57     }
58     
59     public void setBytes(byte[] array) {
60         ByteBuffer buffer = ByteBuffer.wrap(array);
61         buffer.order(ByteOrder.LITTLE_ENDIAN);
62         biSize = buffer.getInt();
63         biWidth = buffer.getInt();
64         biHeight = buffer.getInt();
65         biPlanes = buffer.getShort();
66         biBitCount = buffer.getShort();
67         biCompression = buffer.getInt();
68         biSizeImage = buffer.getInt();
69         biXPelsPerMeter = buffer.getInt();
70         biYPelsPerMeter = buffer.getInt();
71         biClrUsed = buffer.getInt();
72         biClrImportant = buffer.getInt();
73     }
74     
75 }