1 50 51 package com.lowagie.text.pdf.codec.wmf; 52 53 import java.awt.Color ; 54 import java.io.IOException ; 55 import java.io.InputStream ; 56 57 import com.lowagie.text.Utilities; 58 59 public class InputMeta { 60 61 InputStream in; 62 int length; 63 64 public InputMeta(InputStream in) { 65 this.in = in; 66 } 67 68 public int readWord() throws IOException { 69 length += 2; 70 int k1 = in.read(); 71 if (k1 < 0) 72 return 0; 73 return (k1 + (in.read() << 8)) & 0xffff; 74 } 75 76 public int readShort() throws IOException { 77 int k = readWord(); 78 if (k > 0x7fff) 79 k -= 0x10000; 80 return k; 81 } 82 83 public int readInt() throws IOException { 84 length += 4; 85 int k1 = in.read(); 86 if (k1 < 0) 87 return 0; 88 int k2 = in.read() << 8; 89 int k3 = in.read() << 16; 90 return k1 + k2 + k3 + (in.read() << 24); 91 } 92 93 public int readByte() throws IOException { 94 ++length; 95 return in.read() & 0xff; 96 } 97 98 public void skip(int len) throws IOException { 99 length += len; 100 Utilities.skip(in, len); 101 } 102 103 public int getLength() { 104 return length; 105 } 106 107 public Color readColor() throws IOException { 108 int red = readByte(); 109 int green = readByte(); 110 int blue = readByte(); 111 readByte(); 112 return new Color (red, green, blue); 113 } 114 } 115 | Popular Tags |