Package org.apache.sanselan

Examples of org.apache.sanselan.ImageWriteException


  public static TiffOutputField create(TagInfo tagInfo, int byteOrder,
      Number number) throws ImageWriteException
  {
    if (tagInfo.dataTypes == null || tagInfo.dataTypes.length < 1)
      throw new ImageWriteException("Tag has no default data type.");
    FieldType fieldType = tagInfo.dataTypes[0];

    if (tagInfo.length != 1)
      throw new ImageWriteException("Tag does not expect a single value.");

    byte bytes[] = fieldType.writeData(number, byteOrder);

    return new TiffOutputField(tagInfo.tag, tagInfo, fieldType, 1, bytes);
  }
View Full Code Here


  public static TiffOutputField create(TagInfo tagInfo, int byteOrder,
      Number value[]) throws ImageWriteException
  {
    if (tagInfo.dataTypes == null || tagInfo.dataTypes.length < 1)
      throw new ImageWriteException("Tag has no default data type.");
    FieldType fieldType = tagInfo.dataTypes[0];

    if (tagInfo.length != value.length)
      throw new ImageWriteException("Tag does not expect a single value.");

    byte bytes[] = fieldType.writeData(value, byteOrder);

    return new TiffOutputField(tagInfo.tag, tagInfo, fieldType,
        value.length, bytes);
View Full Code Here

    if (tagInfo.dataTypes == null)
      fieldType = FIELD_TYPE_ASCII;
    else if (tagInfo.dataTypes == FIELD_TYPE_DESCRIPTION_ASCII)
      fieldType = FIELD_TYPE_ASCII;
    else
      throw new ImageWriteException("Tag has unexpected data type.");

    byte bytes[] = fieldType.writeData(value, byteOrder);

    return new TiffOutputField(tagInfo.tag, tagInfo, fieldType, 1, bytes);
  }
View Full Code Here

    bos.write4Bytes(count);

    if (isLocalValue())
    {
      if (separateValueItem != null)
        throw new ImageWriteException("Unexpected separate value item.");
      if (bytes.length > 4)
        throw new ImageWriteException(
            "Local value has invalid length: " + bytes.length);

      bos.writeByteArray(bytes);
      int remainder = TIFF_ENTRY_MAX_VALUE_LENGTH - bytes.length;
      for (int i = 0; i < remainder; i++)
        bos.write(0);
    } else
    {
      if (separateValueItem == null)
        throw new ImageWriteException("Missing separate value item.");

      bos.write4Bytes(separateValueItem.getOffset());
    }
  }
View Full Code Here

    // if(tagInfo.isUnknown())
    // Debug.debug("unknown tag(0x" + Integer.toHexString(tag)
    // + ") setData", bytes);

    if (this.bytes.length != bytes.length)
      throw new ImageWriteException("Cannot change size of value.");

    // boolean wasLocalValue = isLocalValue();
    this.bytes = bytes;
    if (separateValueItem != null)
      separateValueItem.updateValue(bytes);
View Full Code Here

        ((Byte) o).byteValue(),
      };
    else if (o instanceof byte[])
      return (byte[]) o;
    else
      throw new ImageWriteException("Invalid data: " + o + " ("
          + Debug.getType(o) + ")");
  }
View Full Code Here

    }

    public void updateValue(byte bytes[]) throws ImageWriteException
    {
      if (this.bytes.length != bytes.length)
        throw new ImageWriteException("Updated data size mismatch: "
            + this.bytes.length + " vs. " + bytes.length);
      System.arraycopy(bytes, 0, this.bytes, 0, bytes.length);
    }
View Full Code Here

      for (int i = 0; i < values.length; i++)
        values[i] = numbers[i].intValue();
      return convertIntArrayToByteArray(values, byteOrder);
    }
    else
      throw new ImageWriteException("Invalid data: " + o + " ("
          + Debug.getType(o) + ")");
  }
View Full Code Here

      for (int i = 0; i < values.length; i++)
        values[i] = numbers[i].doubleValue();
      return convertDoubleArrayToByteArray(values, byteOrder);
    }
    else
      throw new ImageWriteException("Invalid data: " + o + " ("
          + Debug.getType(o) + ")");
  }
View Full Code Here

        ((Byte) o).byteValue(),
      };
    else if (o instanceof byte[])
      return (byte[]) o;
    else
      throw new ImageWriteException("Invalid data: " + o + " ("
          + Debug.getType(o) + ")");
  }
View Full Code Here

TOP

Related Classes of org.apache.sanselan.ImageWriteException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.