@Internal
public class ImageHeaderEMF {
- private static POILogger LOG = POILogFactory.getLogger(ImageHeaderEMF.class);
+ private static final POILogger LOG = POILogFactory.getLogger(ImageHeaderEMF.class);
- private final static String EMF_SIGNATURE = " EMF"; // 0x464D4520 (LE)
-
- // rectangular inclusive-inclusive bounds, in device units, of the smallest
+ private static final String EMF_SIGNATURE = " EMF"; // 0x464D4520 (LE)
+
+ // rectangular inclusive-inclusive bounds, in device units, of the smallest
// rectangle that can be drawn around the image stored in the metafile.
private final Rectangle deviceBounds;
- public ImageHeaderEMF(byte data[], int offset) {
+ public ImageHeaderEMF(final byte data[], final int off) {
+ int offset = off;
int type = (int)LittleEndian.getUInt(data, offset); offset += 4;
if (type != 1) {
LOG.log(POILogger.WARN, "Invalid EMF picture - invalid type");
public Dimension getSize() {
return deviceBounds.getSize();
}
-
+
public Rectangle getBounds() {
return deviceBounds;
}
* skip the first 512 bytes - they are MAC specific crap
*/
public static final int PICT_HEADER_OFFSET = 512;
-
+
public static final double DEFAULT_RESOLUTION = Units.POINT_DPI;
-
+
private static final byte V2_HEADER[] = {
0x00, 0x11, // v2 version opcode
0x02, (byte)0xFF, // version number of new picture
private final Rectangle bounds;
private final double hRes, vRes;
-
- public ImageHeaderPICT(byte data[], int offset) {
- // http://mirrors.apple2.org.za/apple.cabi.net/Graphics/PICT.and_QT.INFO/PICT.file.format.TI.txt
+ public ImageHeaderPICT(byte data[], final int off) {
+ // http://mirrors.apple2.org.za/apple.cabi.net/Graphics/PICT.and_QT.INFO/PICT.file.format.TI.txt
+ int offset = off;
// low order 16 bits of picture size - can be ignored
offset += 2;
// rectangular bounding box of picture, at 72 dpi
break;
}
}
-
+
if (isV2) {
// 4 bytes - fixed, horizontal resolution (dpi) of source data
hRes = readFixedPoint(data, offset); offset += 4;
hRes = DEFAULT_RESOLUTION;
vRes = DEFAULT_RESOLUTION;
}
-
+
bounds = new Rectangle(x1,y1,x2-x1,y2-y1);
}
public Rectangle getBounds() {
return bounds;
}
-
+
private static int readUnsignedShort(byte data[], int offset) {
int b0 = data[offset] & 0xFF;
int b1 = data[offset+1] & 0xFF;
public class ImageHeaderWMF {
public static final int APMHEADER_KEY = 0x9AC6CDD7;
- private static POILogger LOG = POILogFactory.getLogger(ImageHeaderWMF.class);
+ private static final POILogger LOG = POILogFactory.getLogger(ImageHeaderWMF.class);
@SuppressWarnings("unused")
private final int handle;
/**
* The number of logical units per inch used to represent the image.
* This value can be used to scale an image. By convention, an image is
- * considered to be recorded at 1440 logical units (twips) per inch.
+ * considered to be recorded at 1440 logical units (twips) per inch.
* Thus, a value of 720 specifies that the image SHOULD be rendered at
* twice its normal size, and a value of 2880 specifies that the image
* SHOULD be rendered at half its normal size.
*/
- private final int inch;
+ private final int inch;
@SuppressWarnings("unused")
private final int reserved;
private int checksum;
-
+
public ImageHeaderWMF(Rectangle dim) {
handle = 0;
left = dim.x;
reserved = 0;
}
- public ImageHeaderWMF(byte[] data, int pos) {
- int key = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; //header key
+ public ImageHeaderWMF(byte[] data, final int off) {
+ int offset = off;
+ int key = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; //header key
if (key != APMHEADER_KEY) {
LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing");
handle = 0;
return;
}
- handle = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- left = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- top = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- right = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- bottom = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ handle = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE;
+ left = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
+ top = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
+ right = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
+ bottom = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
- inch = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
- reserved = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
+ inch = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE;
+ reserved = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE;
- checksum = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
+ checksum = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE;
if (checksum != getChecksum()){
LOG.log(POILogger.WARN, "WMF checksum does not match the header data");
}
public Rectangle getBounds() {
return new Rectangle(left, top, right-left, bottom-top);
}
-
+
public int getLength(){
return 22;
}