Beispiel #1
0
 public void setSize(int size) {
   if (size > count || size < 0)
     throw new IndexOutOfBoundsException(
         MessageLocalization.getComposedMessage(
             "the.new.size.must.be.positive.and.lt.eq.of.the.current.size"));
   count = size;
 }
Beispiel #2
0
  /**
   * Method to decode LZW compressed data.
   *
   * @param data The compressed data.
   * @param uncompData Array to return the uncompressed data in.
   */
  public void decode(byte data[], OutputStream uncompData) {

    if (data[0] == (byte) 0x00 && data[1] == (byte) 0x01) {
      throw new RuntimeException(
          MessageLocalization.getComposedMessage("lzw.flavour.not.supported"));
    }

    initializeStringTable();

    this.data = data;
    this.uncompData = uncompData;

    // Initialize pointers
    bytePointer = 0;
    bitPointer = 0;

    nextData = 0;
    nextBits = 0;

    int code, oldCode = 0;
    byte string[];

    while ((code = getNextCode()) != 257) {

      if (code == 256) {

        initializeStringTable();
        code = getNextCode();

        if (code == 257) {
          break;
        }

        writeString(stringTable[code]);
        oldCode = code;

      } else {

        if (code < tableIndex) {

          string = stringTable[code];

          writeString(string);
          addStringToTable(stringTable[oldCode], string[0]);
          oldCode = code;

        } else {

          string = stringTable[oldCode];
          string = composeString(string, string[0]);
          writeString(string);
          addStringToTable(string);
          oldCode = code;
        }
      }
    }
  }
Beispiel #3
0
 private void openpfm() throws IOException {
   in.seek(0);
   vers = in.readShortLE();
   h_len = in.readIntLE();
   copyright = readString(60);
   type = in.readShortLE();
   points = in.readShortLE();
   verres = in.readShortLE();
   horres = in.readShortLE();
   ascent = in.readShortLE();
   intleading = in.readShortLE();
   extleading = in.readShortLE();
   italic = (byte) in.read();
   uline = (byte) in.read();
   overs = (byte) in.read();
   weight = in.readShortLE();
   charset = (byte) in.read();
   pixwidth = in.readShortLE();
   pixheight = in.readShortLE();
   kind = (byte) in.read();
   avgwidth = in.readShortLE();
   maxwidth = in.readShortLE();
   firstchar = in.read();
   lastchar = in.read();
   defchar = (byte) in.read();
   brkchar = (byte) in.read();
   widthby = in.readShortLE();
   device = in.readIntLE();
   face = in.readIntLE();
   bits = in.readIntLE();
   bitoff = in.readIntLE();
   extlen = in.readShortLE();
   psext = in.readIntLE();
   chartab = in.readIntLE();
   res1 = in.readIntLE();
   kernpairs = in.readIntLE();
   res2 = in.readIntLE();
   fontname = in.readIntLE();
   if (h_len != in.length() || extlen != 30 || fontname < 75 || fontname > 512)
     throw new IOException(MessageLocalization.getComposedMessage("not.a.valid.pfm.file"));
   in.seek(psext + 14);
   capheight = in.readShortLE();
   xheight = in.readShortLE();
   ascender = in.readShortLE();
   descender = in.readShortLE();
 }