Examples of ImageWriteException


Examples of org.apache.sanselan.ImageWriteException

  protected void setByteOrder(int a, int b) throws ImageWriteException,
      IOException
  {
    if (a != b)
      throw new ImageWriteException("Byte Order bytes don't match (" + a
          + ", " + b + ").");

    if (a == BYTE_ORDER_MOTOROLA)
      byteOrder = a;
    else if (a == BYTE_ORDER_INTEL)
      byteOrder = a;
    else
      throw new ImageWriteException("Unknown Byte Order hint: " + a);
  }
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

      IPTCBlock block = (IPTCBlock) blocks.get(i);

      bos.write(CONST_8BIM);

      if (block.blockType < 0 || block.blockType > 0xffff)
        throw new ImageWriteException("Invalid IPTC block type.");
      bos.write2ByteInteger(block.blockType);

      if (block.blockNameBytes.length > 255)
        throw new ImageWriteException("IPTC block name is too long: "
            + block.blockNameBytes.length);
      bos.write(block.blockNameBytes.length);
      bos.write(block.blockNameBytes);
      if (block.blockNameBytes.length % 2 == 0)
        bos.write(0); // pad to even size, including length byte.

      if (block.blockData.length > IPTC_NON_EXTENDED_RECORD_MAXIMUM_SIZE)
        throw new ImageWriteException("IPTC block data is too long: "
            + block.blockData.length);
      bos.write4ByteInteger(block.blockData.length);
      bos.write(block.blockData);
      if (block.blockData.length % 2 == 1)
        bos.write(0); // pad to even size
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

          continue; // ignore

        bos.write(IPTC_RECORD_TAG_MARKER);
        bos.write(IPTC_APPLICATION_2_RECORD_NUMBER);
        if (element.iptcType.type < 0 || element.iptcType.type > 0xff)
          throw new ImageWriteException("Invalid record type: "
              + element.iptcType.type);
        bos.write(element.iptcType.type);

        byte recordData[] = element.value.getBytes("ISO-8859-1");
        if (!new String(recordData, "ISO-8859-1").equals(element.value))
          throw new ImageWriteException(
              "Invalid record value, not ISO-8859-1");

        bos.write2Bytes(recordData.length);
        bos.write(recordData);
      }
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

  protected final byte[] convertIntArrayToRationalArray(int numerators[],
      int denominators[], int byteOrder) throws ImageWriteException
  {
    if (numerators.length != denominators.length)
      throw new ImageWriteException("numerators.length ("
          + numerators.length + " != denominators.length ("
          + denominators.length + ")");

    byte result[] = new byte[numerators.length * 8];

 
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

    }

    public byte[] encodeValue(FieldType fieldType, Object value,
        int byteOrder) throws ImageWriteException
    {
      throw new ImageWriteException("date encode value: " + value + " ("
          + Debug.getType(value) + ")");
      //      return fieldType.writeData(value, byteOrder);
      //      Object o = entry.fieldType.getSimpleValue(entry);
      //      byte bytes2[];
      //      if (tagInfo.isDate())
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

    public byte[] encodeValue(FieldType fieldType, Object value,
        int byteOrder) throws ImageWriteException
    {
      if (!(value instanceof String))
        throw new ImageWriteException("Text value not String: " + value
            + " (" + Debug.getType(value) + ")");
      String s = (String) value;

      try
      {
        // try ASCII, with NO prefix.
        byte asciiBytes[] = s
            .getBytes(TEXT_ENCODING_ASCII.encodingName);
        String decodedAscii = new String(asciiBytes,
            TEXT_ENCODING_ASCII.encodingName);
        if (decodedAscii.equals(s))
        {
          // no unicode/non-ascii values.
          byte result[] = new byte[asciiBytes.length
              + TEXT_ENCODING_ASCII.prefix.length];
          System.arraycopy(TEXT_ENCODING_ASCII.prefix, 0, result, 0,
              TEXT_ENCODING_ASCII.prefix.length);
          System.arraycopy(asciiBytes, 0, result,
              TEXT_ENCODING_ASCII.prefix.length,
              asciiBytes.length);
          return result;
        }
        else
        {
          // use unicode
          byte unicodeBytes[] = s
              .getBytes(TEXT_ENCODING_UNICODE.encodingName);
          byte result[] = new byte[unicodeBytes.length
              + TEXT_ENCODING_UNICODE.prefix.length];
          System.arraycopy(TEXT_ENCODING_UNICODE.prefix, 0, result,
              0, TEXT_ENCODING_UNICODE.prefix.length);
          System.arraycopy(unicodeBytes, 0, result,
              TEXT_ENCODING_UNICODE.prefix.length,
              unicodeBytes.length);
          return result;
        }
      }
      catch (UnsupportedEncodingException e)
      {
        throw new ImageWriteException(e.getMessage(), e);
      }
    }
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

      params.remove(PARAM_KEY_FORMAT);

    if (params.size() > 0)
    {
      Object firstKey = params.keySet().iterator().next();
      throw new ImageWriteException("Unknown parameter: " + firstKey);
    }

    writer.writeImage(src, os, params);
  }
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

      }
    }

    List result = new ArrayList(segments);
    if (firstAppIndex == -1)
      throw new ImageWriteException("JPEG file has no APP segments.");
    result.addAll(firstAppIndex, newSegments);
    return result;
  }
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

    List result = new ArrayList(segments);
    if (lastAppIndex == -1)
    {
      if(segments.size()<1)
        throw new ImageWriteException("JPEG file has no APP segments.");
      result.addAll(1, newSegments);
    }
    else
    result.addAll(lastAppIndex + 1, newSegments);
   
View Full Code Here

Examples of org.apache.sanselan.ImageWriteException

      params.remove(PARAM_KEY_FORMAT);

    if (params.size() > 0)
    {
      Object firstKey = params.keySet().iterator().next();
      throw new ImageWriteException("Unknown parameter: " + firstKey);
    }

    final SimplePalette palette = new PaletteFactory().makePaletteSimple(
        src, 256);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.