Examples of PngjOutputException


Examples of ar.com.hjg.pngj.PngjOutputException

   **/
  private static boolean shouldWrite(PngChunk c, int currentGroup) {
    if (currentGroup == CHUNK_GROUP_2_PLTE)
      return c.id.equals(ChunkHelper.PLTE);
    if (currentGroup % 2 == 0)
      throw new PngjOutputException("bad chunk group?");
    int minChunkGroup, maxChunkGroup;
    if (c.getOrderingConstraint().mustGoBeforePLTE())
      minChunkGroup = maxChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR;
    else if (c.getOrderingConstraint().mustGoBeforeIDAT()) {
      maxChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE;
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

    while (it.hasNext()) {
      PngChunk c = it.next();
      if (!shouldWrite(c, currentGroup))
        continue;
      if (ChunkHelper.isCritical(c.id) && !c.id.equals(ChunkHelper.PLTE))
        throw new PngjOutputException("bad chunk queued: " + c);
      if (alreadyWrittenKeys.containsKey(c.id) && !c.allowsMultiple())
        throw new PngjOutputException("duplicated chunk does not allow multiple: " + c);
      c.write(os);
      chunks.add(c);
      alreadyWrittenKeys.put(c.id,
          alreadyWrittenKeys.containsKey(c.id) ? alreadyWrittenKeys.get(c.id) + 1 : 1);
      c.setChunkGroup(currentGroup);
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

   */
  public void writeChunk(OutputStream os) {
    writeChunkHeader(os);
    if (len > 0) {
      if (data == null)
        throw new PngjOutputException("cannot write chunk, raw chunk data is null [" + id + "]");
      PngHelperInternal.writeBytes(os, data, 0, len);
    }
    computeCrcForWriting();
    writeChunkCrc(os);
  }
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

    writeChunkCrc(os);
  }

  public void writeChunkHeader(OutputStream os) {
    if (idbytes.length != 4)
      throw new PngjOutputException("bad chunkid [" + id + "]");
    PngHelperInternal.writeInt4(os, len);
    PngHelperInternal.writeBytes(os, idbytes);
  }
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

      } else if (filterType == FilterType.FILTER_ADAPTIVE_FULL) {
        adaptMaxSkip = 0;
        adaptSkipIncreaseSinceRow = 128;
        adaptSkipIncreaseFactor = 1 / 120.0;
      } else
        throw new PngjOutputException("bad filter " + filterType);
    }
  }
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

        if (currentRow == 0)
          skip = 0;
        adaptNextRow = currentRow + 1 + skip;
      }
    } else {
      throw new PngjOutputException("not implemented filter: " + getFilterType());
    }
    if (currentRow == 0 && curfilterType != FilterType.FILTER_NONE
        && curfilterType != FilterType.FILTER_SUB)
      curfilterType = FilterType.FILTER_SUB; // first row should always be none or sub
  }
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

      case FILTER_UP:
        for (i = 1; i <= bytesRow; i++)
          _rowf[i] = (byte) (_rowb[i] - _rowbprev[i]);
        break;
      default:
        throw new PngjOutputException("Filter type not recognized: " + _filterType);
    }
    return _rowf;
  }
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

  @Override
  public void mywrite(byte[] b, int off, int len) {
    if (len == 0)
      return;
    if (done || closed)
      throw new PngjOutputException("write beyond end of stream");
    bytesIn += len;
    while (len > 0) {
      if (inbuf == 0 && (len >= MAX_BUFFER_SIZE || bytesIn == totalbytes)) {
        // direct copy (buffer might be null or empty)
        bytesOut += lz4.compressEstim(b, off, len);
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

  }

  @Override
  public void mywrite(byte[] b, int off, final int len) {
    if (deflater.finished() || done || closed)
      throw new PngjOutputException("write beyond end of stream");
    deflater.setInput(b, off, len);
    bytesIn += len;
    while (!deflater.needsInput())
      deflate();
  }
View Full Code Here

Examples of ar.com.hjg.pngj.PngjOutputException

      bytesOut += len;
      try {
        if (os != null)
          os.write(buf, 0, len);
      } catch (IOException e) {
        throw new PngjOutputException(e);
      }
    }
  }
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.