Examples of InvalidFileStructureException


Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

          "IFF ILBM HAM image file with number of planes " +
          "other than 6 or 8 (got " + numPlanes + ").");
      }
      if (palette == null)
      {
        throw new InvalidFileStructureException("Invalid IFF ILBM " +
          "file: HAM (Hold And Modify) image without a palette.");
      }
      int numPaletteEntries = palette.getNumEntries();
      if (ham6 && numPaletteEntries < 16)
      {
        throw new InvalidFileStructureException("Invalid IFF ILBM " +
          "file: HAM (Hold And Modify) 6 bit image with a " +
          "number of palette entries less than 16 (" +
          numPaletteEntries + ").");
      }
      if (ham8 && numPaletteEntries < 64)
      {
        throw new InvalidFileStructureException("Invalid IFF ILBM " +
          "file: HAM (Hold And Modify) 8 bit image with a " +
          "number of palette entries less than 64 (" +
          numPaletteEntries + ").");
      }
    }
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

      {
        checkAndLoad();
      }
      catch (IOException ioe)
      {
        throw new InvalidFileStructureException("I/O error while loading: " + ioe.toString());
      }
    }
    else
    {
      throw new OperationFailedException("Only loading from IFF is supported.");
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

  {
    while (length > 0)
    {
      if (length < 17)
      {
        throw new InvalidFileStructureException("DHT marker - " +
          "less than 17 bytes left.");
      }
      JPEGHuffmanTable table = new JPEGHuffmanTable();
      int classId = in.readUnsignedByte();
      // class (AC or DC)
      int tableClass = (classId >> 4) & 0x0f;
      if (tableClass != JPEGHuffmanTable.TABLE_CLASS_AC &&
        tableClass != JPEGHuffmanTable.TABLE_CLASS_DC)
      {
        throw new InvalidFileStructureException(
          "Table class in DHT marker is neither AC nor DC.");
      }
      table.setClassAcDc(tableClass);
      // ID
      int tableId = classId & 0x0f;
      table.setId(tableId);
      // codes
      byte[] numCodes = new byte[16];
      in.readFully(numCodes);
      length -= 17;
      int[][] codes = new int[16][];
      for (int codeLength = 1; codeLength <= 16; codeLength++)
      {
        int number = numCodes[codeLength - 1] & 0xff;
        if (length < number)
        {
          throw new InvalidFileStructureException(
            "Not enough data left in DHT marker for codes of " +
            "length " + codeLength + ".");
        }
        codes[codeLength - 1] = new int[number];
        for (int codeIndex = 0; codeIndex < number; codeIndex++)
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

          table.setElementPrecision(16);
          break;
        }
        default:
        {
          throw new InvalidFileStructureException(
            "Not a valid value for quantization table element precision: " +
            elementPrecision + " (expected 0 or 1).");
        }
      }
      int id = precId & 0x0f;
      if (id > 3)
      {
        throw new InvalidFileStructureException(
          "Not a valid quantization table id: " +
          id + " (expected 0 to 3).");
      }
      table.setId(id);
      // check if there's enough data left for the table elements
      int tableDataLength = JPEGConstants.SAMPLES_PER_BLOCK * (elementPrecision + 1);
      if (length < tableDataLength)
      {
        throw new InvalidFileStructureException(
          "Not enough data left in marker for quantization table data: " +
          length + "byte(s) (expected at least " + tableDataLength + ").");
      }
      int[] data = new int[JPEGConstants.SAMPLES_PER_BLOCK];
      for (int i = 0; i < data.length; i++)
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

    IOException,
    UnsupportedTypeException
  {
    if (length < 9)
    {
      throw new InvalidFileStructureException(
        "JPEG SOF header length must be at least nine bytes; got " +
        length + ".");
    }
    byte[] data = new byte[6];
    in.readFully(data);
    JPEGFrame frame = new JPEGFrame();
    // sample precision
    int samplePrecision = data[0] & 0xff;
    if (samplePrecision != 8)
    {
      throw new UnsupportedTypeException("Unsupported JPEG sample precision: " +
        samplePrecision);
    }
    frame.setSamplePrecision(samplePrecision);
    // height
    int height = ArrayConverter.getShortBEAsInt(data, 1);
    if (height < 1)
    {
      throw new InvalidFileStructureException(
        "JPEG SOF height value must be 1 or higher; got " +
        height + ".");
    }
    frame.setHeight(height);
    // width
    int width = ArrayConverter.getShortBEAsInt(data, 3);
    if (width < 1)
    {
      throw new InvalidFileStructureException(
        "JPEG SOF width value must be 1 or higher; got " +
        width + ".");
    }
    frame.setWidth(width);
    // number of components (= channels)
    int numComponents = data[5] & 0xff;
    if (numComponents != 1)
    {
      throw new UnsupportedTypeException("Unsupported number of JPEG components: " +
        numComponents);
    }
    frame.setNumComponents(numComponents);
    if (length - 6 != numComponents * 3)
    {
      throw new InvalidFileStructureException(
        "SOF marker has not expected size for " +
        numComponents + " component(s); got " + length +
        " instead of " + (6 + numComponents * 3));
    }
    JPEGFrameComponent[] frameComponents = new JPEGFrameComponent[numComponents];
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

    IOException,
    UnsupportedTypeException
  {
    if (length < 6)
    {
      throw new InvalidFileStructureException("SOS marker must be at least six bytes large; got " + length);
    }
    int numScanComponents = in.readUnsignedByte();
    length--;
    if (numScanComponents < 1)
    {
      throw new InvalidFileStructureException("Number of scan components must be one or larger.");
    }
    JPEGScan scan = new JPEGScan();
    scan.setNumComponents(numScanComponents);
    JPEGScanComponentSpecification[] specs = new JPEGScanComponentSpecification[numScanComponents];
    byte[] data = new byte[2];
    for (int i = 0; i < numScanComponents; i++)
    {
      in.readFully(data);
      length -= 2;
      int componentSelector = data[0] & 0xff;
      int dcTableSelector = (data[1] & 0xf0) >> 4;
      int acTableSelector = data[1] & 0x0f;
      JPEGScanComponentSpecification spec = new JPEGScanComponentSpecification();
      spec.setAcEntropyTable(acTableSelector);
      spec.setDcEntropyTable(dcTableSelector);
      spec.setComponent(componentSelector);
      specs[i] = spec;
    }
    scan.setCompSpecs(specs);
    if (length != 3)
    {
      throw new InvalidFileStructureException(
        "Expected exactly three bytes left after scan component specs; got " +
        length);
    }
    data = new byte[3];
    in.readFully(data);
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

      throw new WrongFileFormatException("Not a BMP file (first two bytes are not 0x42 0x4d).");
    }
    dataOffset = ArrayConverter.getIntLE(header, 0x0a);
    if (dataOffset < 54)
    {
      throw new InvalidFileStructureException("BMP data expected to be 54dec or larger, got " + dataOffset);
    }
    imageWidth = ArrayConverter.getIntLE(header, 0x12);
    imageHeight = ArrayConverter.getIntLE(header, 0x16);
    if (imageWidth < 1 || imageHeight < 1)
    {
      throw new InvalidFileStructureException("BMP image width and height must be larger than 0, got " + imageWidth + " x " + imageHeight);
    }
    int planes = ArrayConverter.getShortLE(header, 0x1a);
    if (planes != 1)
    {
      throw new InvalidFileStructureException("Can only handle BMP number of planes = 1, got " + planes);
    }
    colorDepth = ArrayConverter.getShortLE(header, 0x1c);
    if (colorDepth != 1 && colorDepth != 4 && colorDepth != 8 && colorDepth != 24)
    {
      // TO DO: add support for 16 bpp BMP reading
      throw new InvalidFileStructureException("Unsupported BMP color depth: " + colorDepth);
    }
    compression = ArrayConverter.getIntLE(header, 0x1e);
    if (compression != 0 && !(compression == 1 && colorDepth == 8) && !(compression == 2 && colorDepth == 4))
    {
      throw new InvalidFileStructureException("Unsupported BMP compression type / color depth combination: " +
        compression + " / " + colorDepth);
    }
    float dpiXValue = ArrayConverter.getIntLE(header, 0x26) / (100.0f / 2.54f);
    float dpiYValue = ArrayConverter.getIntLE(header, 0x2a) / (100.0f / 2.54f);
    setDpi((int)dpiXValue, (int)dpiYValue);
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

      int expectedPaletteSize = 4 * numPaletteEntries;
      int headerSpaceLeft = dataOffset - 54;
      bytesToSkip = headerSpaceLeft - expectedPaletteSize;
      if (bytesToSkip < 0)
      {
        throw new InvalidFileStructureException("Not enough space in header for palette with " +
          numPaletteEntries + "entries.");
      }
      palette = new Palette(numPaletteEntries);
      for (int index = 0; index < numPaletteEntries; index++)
      {
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

        {
          numInflated = inflater.inflate(data, 0, numBytes);
        }
        catch (DataFormatException dfe)
        {
          throw new InvalidFileStructureException("Error in compressed input data: " + dfe.toString());
        }
        // store decompressed data and update number of bytes left to decompress
        if (numInflated > 0)
        {
          putBytes(data, 0, numInflated);
View Full Code Here

Examples of net.sourceforge.jiu.codecs.InvalidFileStructureException

            int num = in.readUnsignedByte();
            if (num < 1 || index + num > bytesPerRow)
            {
              String message = "At index=" + index + ", y=" + y + " there is a run length of " + num;
              System.err.println("ERROR decoding RLE: " + message);
              throw new InvalidFileStructureException(message);
            }
            byte value = in.readByte();
            while (num-- > 0)
            {
              row[index++] = value;
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.