Package processing.core

Examples of processing.core.PImage


    //cut the image into slices
    for (int row = 0; row < _tileImage.height / _tileHeight; row++) {
      for (int col = 0; col < _tileImage.width / _tileWidth; col++) {
        //Create a new image slice that corresponds to the size of the tiles in this set
        PImage slice = Hermes.getPApplet().createImage(_tileWidth, _tileHeight, Hermes.getPApplet().ARGB);
        //Copy pixels from the originally sourced image
        slice.copy(_tileImage, col * _tileWidth, row * _tileHeight, _tileWidth,  _tileHeight, 0, 0, _tileWidth, _tileHeight);

        _slicedTiles[row][col] = slice; //add the slice to our array of slices
      }
    }
  }
View Full Code Here


   * @param shotY
   *            Current y position of the large image to store the current screenshot to.
   */
  protected void renderAndMakeSnapshot(int shotX, int shotY) {
    PApplet.println("Making snapshot for " + shotX + ", " + shotY);
    PImage currentImage = makeSnapshot();
    largeImage.beginDraw();
    largeImage.image(currentImage, shotX, shotY);
    largeImage.endDraw();
  }
View Full Code Here

          pg.pushMatrix();
          pg.scale(1.0f / PApplet.pow(2, coord.zoom));
        }

        if (images.containsKey(coord)) {
          PImage tile = (PImage) images.get(coord);

          float x = coord.column * TILE_WIDTH;
          float y = coord.row * TILE_HEIGHT;

          // REVISIT For transparency, do not paint image (why no transparent imgs?)
View Full Code Here

   * @param jdbcConnectionString
   *            The path to the MBTiles database.
   * @return The tile as PImage, or null if not found.
   */
  public static PImage getMBTile(int column, int row, int zoomLevel, String jdbcConnectionString) {
    PImage img = null;
    try {
      byte[] tileData = getMBTileData(column, row, zoomLevel, jdbcConnectionString);
      if (tileData != null) {
        img = getAsImage(tileData);
      } else {
View Full Code Here

    }
   
    try {
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
      BufferedImage bimg = ImageIO.read(bis);
      PImage img = new PImage(bimg.getWidth(), bimg.getHeight(), PConstants.ARGB);
      bimg.getRGB(0, 0, img.width, img.height, img.pixels, 0, img.width);
      img.updatePixels();
      return img;
    } catch (Exception e) {
      System.err.println("Can't create image from buffer");
      e.printStackTrace();
      return null;
View Full Code Here

    this.p = p;
    this.provider = provider;
    this.listener = listener;
    this.coordinate = coordinate;

    cachedEmpyImage = new PImage(provider.tileWidth(), provider.tileHeight(), PConstants.ARGB);
  }
View Full Code Here

   * afterwards.
   */
  public void run() {

    // Gets tile as image directly from provider (e.g. loaded from a database)
    PImage tileImg = provider.getTile(coordinate);

    if (tileImg == null) {
      // Loads images via the tile URLs from provider (e.g. from a web map service)
      String[] urls = provider.getTileUrls(coordinate);
      if (urls != null) {
View Full Code Here

   * @return The tile image.
   */
  protected PImage getTileFromUrl(String[] urls) {
    // Load image from URL (local file included)
    // NB: Use 'unknown' as content-type to let loadImage decide
    PImage img = p.loadImage(urls[0], "unknown");
    //PImage img = p.loadImage(urls[0]); // test for Android

    if (img != null) {
      // If array contains multiple URLs, load all images and blend them together
      for (int i = 1; i < urls.length; i++) {
        PImage img2 = p.loadImage(urls[i], "unknown");
        if (img2 != null) {
          img.blend(img2, 0, 0, img.width, img.height, 0, 0, img.width, img.height, PApplet.BLEND);
        }
      }
    }
View Full Code Here

    temp.smooth();
    temp.translate(temp.width / 2, temp.height / 2);
    temp.imageMode(PConstants.CENTER);
    temp.image(img, 0, 0);
    temp.endDraw();
    PImage saveArea = p.createImage(temp.width, temp.height, PConstants.ARGB);
    for (int y = 0; y < saveArea.height; y++) {
      for (int x = 0; x < saveArea.width; x++) {
        int index = y + x * saveArea.width;
        float d = PApplet.dist(x, y, radius, radius);
        if (d > radius) {
          saveArea.pixels[index] = 0;
        } else if (d >= radius - feather) {
          int c = temp.pixels[index];
          int r = (c >> 16) & 0xff;
          int g = (c >> 8) & 0xff;
          int b = (c) & 0xff;
          c = p.color(r, g, b, PApplet.map(d, radius - feather, radius, 255, 0));
          saveArea.pixels[index] = c;
        } else {
          saveArea.pixels[index] = temp.pixels[index];
        }
      }
    }
    saveArea.updatePixels();
    return saveArea;
  }
View Full Code Here

    temp.smooth();
    temp.translate(temp.width / 2, temp.height / 2);
    temp.imageMode(PConstants.CENTER);
    temp.image(img, 0, 0);
    temp.endDraw();
    PImage saveArea = p.createImage(temp.width, temp.height, PConstants.ARGB);
    for (int y = 0; y < saveArea.height; y++) {
      for (int x = 0; x < saveArea.width; x++) {
        int index = y + x * saveArea.width;
        float d = PApplet.dist(x, y, radius, radius);
        if (d > radius) {
          saveArea.pixels[index] = 0;
        } else if (d >= radius - feather) {
          int c = temp.pixels[index];
          int r = (c >> 16) & 0xff;
          int g = (c >> 8) & 0xff;
          int b = (c) & 0xff;
          c = p.color(r, g, b, PApplet.map(d, radius - feather, radius, 255, 0));
          saveArea.pixels[index] = c;
        } else {
          saveArea.pixels[index] = temp.pixels[index];
        }
      }
    }
    saveArea.updatePixels();
    return saveArea;
  }
View Full Code Here

TOP

Related Classes of processing.core.PImage

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.