Examples of Box2i


Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

      out.flush();
    }
    out.writeByte(0);

    CompressionMethod cm = getCompressionMethod();
    Box2i dw = getDataWindow();
    int xmin = dw.getXMin();
    int ymin = dw.getYMin();
    int xmax = dw.getXMax();
    int ymax = dw.getYMax();

    int numBlocks = dw.getYSize() / cm.getScanLinesPerBlock();
    long blockPtrPos = out.getStreamPosition();
    long blockPos = blockPtrPos + 8 * numBlocks;

    int maximumBlockSize = computeMaximumTileSize(new V2i(dw.getXSize(),
        Math.min(dw.getYSize(), cm.getScanLinesPerBlock())));
    byte[] blockData = new byte[maximumBlockSize];
    IIOByteBuffer buf = new IIOByteBuffer(null, 0, 0);
    ByteBuffer bytes = ByteBuffer.wrap(blockData).order(ByteOrder.LITTLE_ENDIAN);

    int firstBlock;
    int lastBlock;
    int blockIncr;
    switch (getLineOrder()) {
    case INCREASING_Y:
    case RANDOM_Y:
      firstBlock = 0;
      lastBlock = numBlocks;
      blockIncr = 1;
      break;

    case DECREASING_Y:
      firstBlock = numBlocks - 1;
      lastBlock = -1;
      blockIncr = -1;
      break;

    default:
      throw new UnexpectedException("Invalid line order");
    }

    for (int i = firstBlock; i != lastBlock; i += blockIncr) {
      out.seek(blockPtrPos + 8 * i);
      out.writeLong(blockPos - start);
      out.seek(blockPos);
      bytes.rewind();

      // TODO write the next block here
      int x0 = dw.getXMin();
      int x1 = dw.getXMax();
      int y0 = dw.getYMin() + i * cm.getScanLinesPerBlock();
      int y1 = Math.min(y0 + cm.getScanLinesPerBlock() - 1, dw.getYMax());
      Box2i block = new Box2i(x0, y0, x1, y1);
      int blockSize = computeTileSize(block);

      for (int y = y0; y <= y1; y++) {
        for (Channel channel : chlist.channels()) {
          String name = channel.getName();
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

    setFloat(x, y, "B", (float) rgb.b());
  }

  public long getUnsignedInt(int x, int y, String c) {
    Channel ch = getChannelList().getChannel(c);
    Box2i dw = getDataWindow();
    int xmin = dw.getXMin();
    int ymin = dw.getYMin();
    int sx = ch.getxSampling();
    int sy = ch.getySampling();
    int x0 = (x - xmin) / sx;
    int y0 = (y - ymin) / sy;
    int w0 = dw.getXSize() / sx;
    int index = y0 * w0 + x0;

    switch (ch.getPixelType()) {
    case UINT:
      IntBuffer ibuf = (IntBuffer) getChannelBuffer(c);
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

    }
  }

  public Half getHalf(int x, int y, String c) {
    Channel ch = getChannelList().getChannel(c);
    Box2i dw = getDataWindow();
    int sx = ch.getxSampling();
    int sy = ch.getySampling();
    int xmin = dw.getXMin();
    int ymin = dw.getYMin();
    int x0 = (x - xmin) / sx;
    int y0 = (y - ymin) / sy;
    int w0 = dw.getXSize() / sx;
    int index = y0 * w0 + x0;

    switch (ch.getPixelType()) {
    case UINT:
      IntBuffer ibuf = (IntBuffer) getChannelBuffer(c);
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

    }
  }

  public float getFloat(int x, int y, String c) {
    Channel ch = getChannelList().getChannel(c);
    Box2i dw = getDataWindow();
    int sx = ch.getxSampling();
    int sy = ch.getySampling();
    int xmin = dw.getXMin();
    int ymin = dw.getYMin();
    int x0 = (x - xmin) / sx;
    int y0 = (y - ymin) / sy;
    int w0 = dw.getXSize() / sx;
    int index = y0 * w0 + x0;

    switch (ch.getPixelType()) {
    case UINT:
      IntBuffer ibuf = (IntBuffer) getChannelBuffer(c);
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

    }
  }

  public void setUnsignedInt(int x, int y, String c, long value) {
    Channel ch = getChannelList().getChannel(c);
    Box2i dw = getDataWindow();
    int sx = ch.getxSampling();
    int sy = ch.getySampling();
    int xmin = dw.getXMax();
    int ymin = dw.getYMin();
    int x0 = (x - xmin) / sx;
    int y0 = (y - ymin) / sy;
    int w0 = dw.getXSize() / sx;
    int index = y0 * w0 + x0;

    switch (ch.getPixelType()) {
    case UINT:
      IntBuffer ibuf = (IntBuffer) getChannelBuffer(c);
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

    }
  }

  public void setHalf(int x, int y, String c, Half value) {
    Channel ch = getChannelList().getChannel(c);
    Box2i dw = getDataWindow();
    int sx = ch.getxSampling();
    int sy = ch.getySampling();
    int x0 = x / sx;
    int y0 = y / sy;
    int w0 = dw.getXSize() / sx;
    int index = y0 * w0 + x0;

    switch (ch.getPixelType()) {
    case UINT:
      IntBuffer ibuf = (IntBuffer) getChannelBuffer(c);
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

    }
  }

  public void setFloat(int x, int y, String c, float value) {
    Channel ch = getChannelList().getChannel(c);
    Box2i dw = getDataWindow();
    int sx = ch.getxSampling();
    int sy = ch.getySampling();
    int x0 = x / sx;
    int y0 = y / sy;
    int w0 = dw.getXSize() / sx;
    int index = y0 * w0 + x0;

    switch (ch.getPixelType()) {
    case UINT:
      IntBuffer ibuf = (IntBuffer) getChannelBuffer(c);
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

  private final Map<String, Attribute> attributes = new HashMap<String, Attribute>();

  private final Map<String, Buffer> data = new HashMap<String, Buffer>();

  public OpenEXRImage(int w, int h) {
    this(new Box2i(0, 0, w - 1, h - 1));
  }
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

      source.seek(source.getFlushedPosition() + size);
      source.flush();
    }

    Box2i dw = getDataWindow();
    CompressionMethod cm = getCompressionMethod();

    source.flush();

    if (tiled) {
      TileDescription td = getTiles();
      int numTiles;
      switch (td.getLevelMode()) {
      case ONE_LEVEL:
        numTiles = (1 + (dw.getYSize() - 1) / td.getYSize())
            * (1 + (dw.getXSize() - 1) / td.getXSize());
        break;

      case MIPMAP_LEVELS:
      {
        int w = dw.getXSize();
        int h = dw.getYSize();
        int tw = td.getXSize();
        int th = td.getYSize();
        RoundingMode rm = td.getRoundingMode();
        int n = 1 + round(Math.log(Math.max(w, h)) / Math.log(2.0), rm);
        numTiles = 0;
        for (int i = 0; i < n; i++) {
          int lx = round(w / Math.pow(2.0, i), rm);
          int ly = round(h / Math.pow(2.0, i), rm);
          int tx = 1 + (lx - 1) / tw;
          int ty = 1 + (ly - 1) / th;
          numTiles += tx * ty;
        }
        break;
      }

      case RIPMAP_LEVELS:
      {
        int w = dw.getXSize();
        int h = dw.getYSize();
        int tw = td.getXSize();
        int th = td.getYSize();
        RoundingMode rm = td.getRoundingMode();
        int nx = 1 + round(Math.log(w) / Math.log(2.0), rm);
        int ny = 1 + round(Math.log(h) / Math.log(2.0), rm);
        numTiles = 0;
        for (int j = 0; j < ny; j++) {
          int ly = round(h / Math.pow(2.0, j), rm);
          int ty = 1 + (ly - 1) / th;
          for (int i = 0; i < nx; i++) {
            int lx = round(w / Math.pow(2.0, i), rm);
            int tx = 1 + (lx - 1) / tw;
            numTiles += tx * ty;
          }
        }
        break;
      }

      default:
        throw new UnexpectedException("Invalid level mode.");
      }
      source.seek(source.getFlushedPosition() + 8 * numTiles);
      source.flush();

      throw new UnimplementedException();

    } else { // scan lines
      int w = dw.getXSize();
      int h = dw.getYSize();
      int ymin = dw.getYMin();
      int ymax = dw.getYMax();
      int blockHeight = cm.getScanLinesPerBlock();
      int numBlocks = 1 + (h - 1) / blockHeight;
      ChannelList chlist = getChannelList();

      source.seek(source.getFlushedPosition() + 8 * numBlocks);

      for (int i = 0; i < numBlocks; i++) {
        source.flush();

        int x0 = dw.getXMin();
        int x1 = dw.getXMax();
        int y0 = source.readInt();
        int y1 = Math.min(y0 + blockHeight - 1, ymax);
        Box2i block = new Box2i(x0, y0, x1, y1);
        int size = source.readInt();
        int blockSize = computeTileSize(block);

        IIOByteBuffer buf = new IIOByteBuffer(null, 0, 0);
        source.readBytes(buf, size);
View Full Code Here

Examples of ca.eandb.jmist.framework.loader.openexr.attribute.Box2i

  private synchronized Buffer getChannelBufferSync(String name) {
    Buffer buf = data.get(name);
    if (buf == null) {
      ChannelList chlist = getChannelList();
      Channel channel = chlist.getChannel(name);
      Box2i dataWindow = getDataWindow();
      int w = dataWindow.getXSize();
      int h = dataWindow.getYSize();
      int sx = 1 + (w - 1) / channel.getxSampling();
      int sy = 1 + (h - 1) / channel.getySampling();
      PixelType pt = channel.getPixelType();

      switch (pt) {
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.