| 1 |
// Copyright 2002, FreeHEP. |
| 2 |
package org.freehep.graphicsio.emf.gdi; |
| 3 |
|
| 4 |
import java.io.IOException; |
| 5 |
|
| 6 |
import org.freehep.graphicsio.emf.EMFConstants; |
| 7 |
import org.freehep.graphicsio.emf.EMFInputStream; |
| 8 |
import org.freehep.graphicsio.emf.EMFOutputStream; |
| 9 |
|
| 10 |
/** |
| 11 |
* EMF BitmapInfoHeader |
| 12 |
* |
| 13 |
* @author Mark Donszelmann |
| 14 |
* @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/BitmapInfoHeader.java 10ec7516e3ce 2007/02/06 18:42:34 duns $ |
| 15 |
*/ |
| 16 |
public class BitmapInfoHeader implements EMFConstants { |
| 17 |
|
| 18 |
public static final int size = 40; |
| 19 |
|
| 20 |
private int width; |
| 21 |
|
| 22 |
private int height; |
| 23 |
|
| 24 |
private int planes; |
| 25 |
|
| 26 |
private int bitCount; |
| 27 |
|
| 28 |
private int compression; |
| 29 |
|
| 30 |
private int sizeImage; |
| 31 |
|
| 32 |
private int xPelsPerMeter; |
| 33 |
|
| 34 |
private int yPelsPerMeter; |
| 35 |
|
| 36 |
private int clrUsed; |
| 37 |
|
| 38 |
private int clrImportant; |
| 39 |
|
| 40 |
public BitmapInfoHeader(int width, int height, int bitCount, |
| 41 |
int compression, int sizeImage, int xPelsPerMeter, |
| 42 |
int yPelsPerMeter, int clrUsed, int clrImportant) { |
| 43 |
this.width = width; |
| 44 |
this.height = height; |
| 45 |
this.planes = 1; |
| 46 |
this.bitCount = bitCount; |
| 47 |
this.compression = compression; |
| 48 |
this.sizeImage = sizeImage; |
| 49 |
this.xPelsPerMeter = xPelsPerMeter; |
| 50 |
this.yPelsPerMeter = yPelsPerMeter; |
| 51 |
this.clrUsed = clrUsed; |
| 52 |
this.clrImportant = clrImportant; |
| 53 |
} |
| 54 |
|
| 55 |
public BitmapInfoHeader(EMFInputStream emf) throws IOException { |
| 56 |
/*int len = */ emf.readDWORD(); // seems fixed |
| 57 |
width = emf.readLONG(); |
| 58 |
height = emf.readLONG(); |
| 59 |
planes = emf.readWORD(); |
| 60 |
bitCount = emf.readWORD(); |
| 61 |
compression = emf.readDWORD(); |
| 62 |
sizeImage = emf.readDWORD(); |
| 63 |
xPelsPerMeter = emf.readLONG(); |
| 64 |
yPelsPerMeter = emf.readLONG(); |
| 65 |
clrUsed = emf.readDWORD(); |
| 66 |
clrImportant = emf.readDWORD(); |
| 67 |
} |
| 68 |
|
| 69 |
public void write(EMFOutputStream emf) throws IOException { |
| 70 |
emf.writeDWORD(size); |
| 71 |
emf.writeLONG(width); |
| 72 |
emf.writeLONG(height); |
| 73 |
emf.writeWORD(planes); |
| 74 |
emf.writeWORD(bitCount); |
| 75 |
emf.writeDWORD(compression); |
| 76 |
emf.writeDWORD(sizeImage); |
| 77 |
emf.writeLONG(xPelsPerMeter); |
| 78 |
emf.writeLONG(yPelsPerMeter); |
| 79 |
emf.writeDWORD(clrUsed); |
| 80 |
emf.writeDWORD(clrImportant); |
| 81 |
} |
| 82 |
|
| 83 |
public String toString() { |
| 84 |
return " size: " + size + |
| 85 |
"\n width: " + width + |
| 86 |
"\n height: " + height + |
| 87 |
"\n planes: " + planes + |
| 88 |
"\n bitCount: " + bitCount + |
| 89 |
"\n compression: " + compression + |
| 90 |
"\n sizeImage: " + sizeImage + |
| 91 |
"\n xPelsPerMeter: " + xPelsPerMeter + |
| 92 |
"\n yPelsPerMeter: " + yPelsPerMeter + |
| 93 |
"\n clrUsed: " + clrUsed + |
| 94 |
"\n clrImportant: " + clrImportant; |
| 95 |
} |
| 96 |
|
| 97 |
public int getBitCount() { |
| 98 |
return bitCount; |
| 99 |
} |
| 100 |
|
| 101 |
public int getCompression() { |
| 102 |
return compression; |
| 103 |
} |
| 104 |
|
| 105 |
public int getClrUsed() { |
| 106 |
return clrUsed; |
| 107 |
} |
| 108 |
|
| 109 |
public int getWidth() { |
| 110 |
return width; |
| 111 |
} |
| 112 |
|
| 113 |
public int getHeight() { |
| 114 |
return height; |
| 115 |
} |
| 116 |
} |