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;
19 * WIN32 API BITMAPINFOHEADER
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
26 @SuppressWarnings("restriction")
27 public class BitmapInfoHeader {
31 public short biPlanes;
32 public short biBitCount;
33 public int biCompression;
34 public int biSizeImage;
35 public int biXPelsPerMeter;
36 public int biYPelsPerMeter;
38 public int biClrImportant;
39 public static final int sizeof = 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);
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();