Package ar.com.hjg.pngj

Examples of ar.com.hjg.pngj.PngjException


  }

  @Override
  public void parseFromRaw(ChunkRaw chunk) {
    if (chunk.len != 4)
      throw new PngjException("bad chunk " + chunk);
    int g = PngHelperInternal.readInt4fromBytes(chunk.data, 0);
    gamma = ((double) g) / 100000.0;
  }
View Full Code Here


      byte[] b = ba.toByteArray();
      ChunkRaw chunk = createEmptyChunk(b.length, false);
      chunk.data = b;
      return chunk;
    } catch (IOException e) {
      throw new PngjException(e);
    }
  }
View Full Code Here

        t = i;
        break;
      }
    }
    if (t <= 0 || t > c.data.length - 2)
      throw new PngjException("bad sPLT chunk: no separator found");
    palName = ChunkHelper.toString(c.data, 0, t);
    sampledepth = PngHelperInternal.readInt1fromByte(c.data, t + 1);
    t += 2;
    int nentries = (c.data.length - t) / (sampledepth == 8 ? 6 : 10);
    palette = new int[nentries * 5];
 
View Full Code Here

  }

  @Override
  public ChunkRaw createRawChunk() {
    if (key == null || key.trim().length() == 0)
      throw new PngjException("Text chunk key must be non empty");
    try {
      ByteArrayOutputStream ba = new ByteArrayOutputStream();
      ba.write(ChunkHelper.toBytes(key));
      ba.write(0); // separator
      ba.write(0); // compression method: 0
      byte[] textbytes = ChunkHelper.compressBytes(ChunkHelper.toBytes(val), true);
      ba.write(textbytes);
      byte[] b = ba.toByteArray();
      ChunkRaw chunk = createEmptyChunk(b.length, false);
      chunk.data = b;
      return chunk;
    } catch (IOException e) {
      throw new PngjException(e);
    }
  }
View Full Code Here

        continue;
      nullsep = i;
      break;
    }
    if (nullsep < 0 || nullsep > c.data.length - 2)
      throw new PngjException("bad zTXt chunk: no separator found");
    key = ChunkHelper.toString(c.data, 0, nullsep);
    int compmet = (int) c.data[nullsep + 1];
    if (compmet != 0)
      throw new PngjException("bad zTXt chunk: unknown compression method");
    byte[] uncomp =
        ChunkHelper.compressBytes(c.data, nullsep + 2, c.data.length - nullsep - 2, false); // uncompress
    val = ChunkHelper.toString(uncomp);
  }
View Full Code Here

  }

  @Override
  public ChunkRaw createRawChunk() {
    if (key == null || key.trim().length() == 0)
      throw new PngjException("Text chunk key must be non empty");
    byte[] b = ChunkHelper.toBytes(key + "\0" + val);
    ChunkRaw chunk = createEmptyChunk(b.length, false);
    chunk.data = b;
    return chunk;
  }
View Full Code Here

  }

  @Override
  public void parseFromRaw(ChunkRaw c) {
    if (c.len != 32)
      throw new PngjException("bad chunk " + c);
    whitex = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 0));
    whitey = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 4));
    redx = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 8));
    redy = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 12));
    greenx = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 16));
View Full Code Here

  }

  @Override
  public void parseFromRaw(ChunkRaw c) {
    if (c.len != 1)
      throw new PngjException("bad chunk length " + c);
    intent = PngHelperInternal.readInt1fromByte(c.data, 0);
  }
View Full Code Here

  }

  @Override
  public void parseFromRaw(ChunkRaw c) {
    if (c.len != getCLen())
      throw new PngjException("bad chunk length " + c);
    if (imgInfo.greyscale) {
      graysb = PngHelperInternal.readInt1fromByte(c.data, 0);
      if (imgInfo.alpha)
        alphasb = PngHelperInternal.readInt1fromByte(c.data, 1);
    } else {
View Full Code Here

    return c;
  }

  public void setGraysb(int gray) {
    if (!imgInfo.greyscale)
      throw new PngjException("only greyscale images support this");
    graysb = gray;
  }
View Full Code Here

TOP

Related Classes of ar.com.hjg.pngj.PngjException

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.