Ejemplo n.º 1
0
  public BufferedImage createThumbnailImage(
      int x, int y, long w, long h, int maxSize, int bufferedImageType) throws IOException {
    double ds;

    if (w > h) {
      ds = (double) w / maxSize;
    } else {
      ds = (double) h / maxSize;
    }

    if (ds < 1.0) {
      ds = 1.0;
    }

    int sw = (int) (w / ds);
    int sh = (int) (h / ds);
    int sx = (int) (x / ds);
    int sy = (int) (y / ds);

    BufferedImage result = new BufferedImage(sw, sh, bufferedImageType);

    Graphics2D g = result.createGraphics();

    // vartika says on 3 august
    // vartika doubt on 3 august - where is this draw being called from? need to move it to client

    ReturnObject returnObject = paintRegion(sx, sy, sw, sh, ds);
    g.drawImage(returnObject.getImg(), 0, 0, returnObject.getW(), returnObject.getH(), null);

    if (debug) {
      System.out.println(returnObject.getImg());

      if (debugThingy == 0) {
        g.setColor(new Color(1.0f, 0.0f, 0.0f, 0.4f));
        debugThingy = 1;
      } else {
        g.setColor(new Color(0.0f, 1.0f, 0.0f, 0.4f));
        debugThingy = 0;
      }
      g.fillRect(0, 0, returnObject.getW(), returnObject.getH());
    }

    g.dispose();
    return result;
  }
Ejemplo n.º 2
0
  // vartika says - to change this tomorrow
  public void paintRegionOfLevel(
      Graphics2D g, int dx, int dy, int sx, int sy, int w, int h, int level) throws IOException {

    // vartika says on 3 august
    // paintRegion(g, dx, dy, sx, sy, w, h, levelDownsamples[level]);
    ReturnObject returnObject = paintRegion(sx, sy, w, h, levelDownsamples[level]);

    // vartika doubt on 3 august - shouldn't this be at client?? -who calls it?
    g.drawImage(returnObject.getImg(), dx, dy, w, h, null);

    if (debug) {
      System.out.println(returnObject.getImg());

      if (debugThingy == 0) {
        g.setColor(new Color(1.0f, 0.0f, 0.0f, 0.4f));
        debugThingy = 1;
      } else {
        g.setColor(new Color(0.0f, 1.0f, 0.0f, 0.4f));
        debugThingy = 0;
      }
      g.fillRect(dx, dy, returnObject.getW(), returnObject.getH());
    }
  }