Package processing.core

Examples of processing.core.PImage


  public static PImage imgResize(PImage img,float w) {
    BufferedImage tmp=(BufferedImage )img.getImage();
    float mod=w/(float)tmp.getWidth();
//    log("mod "+mod+" dim "+tmp.getWidth()+" "+tmp.getHeight());
   
    PImage tmp2=new PImage(tmp.getScaledInstance(
        (int)w, (int)Math.round((float)tmp.getHeight()*mod),  
        java.awt.Image.SCALE_SMOOTH));
   
//    log("mod "+mod+" dim "+tmp2.width+" "+tmp2.height);

View Full Code Here


  public static PImage imgResize(PImage img,float w) {
    BufferedImage tmp=(BufferedImage )img.getImage();
    float mod=w/(float)tmp.getWidth();
//    log("mod "+mod+" dim "+tmp.getWidth()+" "+tmp.getHeight());
   
    PImage tmp2=new PImage(tmp.getScaledInstance(
        (int)w, (int)Math.round((float)tmp.getHeight()*mod),  
        java.awt.Image.SCALE_SMOOTH));
   
//    log("mod "+mod+" dim "+tmp2.width+" "+tmp2.height);

View Full Code Here

  public static PImage imgResize(PImage img,float w) {
    BufferedImage tmp=(BufferedImage )img.getImage();
    float mod=w/(float)tmp.getWidth();
//    log("mod "+mod+" dim "+tmp.getWidth()+" "+tmp.getHeight());
   
    PImage tmp2=new PImage(tmp.getScaledInstance(
        (int)w, (int)Math.round((float)tmp.getHeight()*mod),  
        java.awt.Image.SCALE_SMOOTH));
   
//    log("mod "+mod+" dim "+tmp2.width+" "+tmp2.height);

View Full Code Here

  /**
   * helper function to load the large pixelinvaders logo
   * @return
   */
  public static Image createLargeIcon(PApplet papplet) {
      PImage img = papplet.loadImage("pics/logoBig.jpg");
      if (img!=null) {
          return img.getImage();         
      }
      LOG.log(Level.WARNING, "failed to load icon image!");
      img = new PImage(400,400);
      return img.getImage();
  }
View Full Code Here

    //Put buffered image into PImage pixels
     BufferedImage bi = img;
        int width = bi.getWidth();
        int height = bi.getHeight();
        if (tempImage == null){
          tempImage = new PImage(width, height);
          tempImage.loadPixels();
        }
        WritableRaster raster = bi.getRaster();
        raster.getDataElements(0, 0, width, height, tempImage.pixels);
//    */
 
View Full Code Here

   */
  public void addScene(ICreateScene sceneToCreate, PImage icon){
//    System.out.println("Width: " + width + " Height:" + height);
   
    //Create reflection image
    PImage reflection = this.getReflection(getMTApplication(), icon);
   
    float border = 1;
    float bothBorders = 2*border;
    float topShift = 30;
    float reflectionDistanceFromImage = topShift + gapBetweenIconAndReflection; //Gap width between image and reflection
View Full Code Here

   */
  private PImage getReflection(PApplet pa, PImage image) {
    int width =  image.width;
    int height = image.height;
   
    PImage copyOfImage = pa.createImage(image.width, image.height, PApplet.ARGB);
    image.loadPixels();
    copyOfImage.loadPixels();
      
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        int imageIndex = y*image.width+x;
//        int currA = (image.pixels[imageIndex] >> 32) & 0xFF;
        int currR = (image.pixels[imageIndex] >> 16) & 0xFF;
          int currG = (image.pixels[imageIndex] >> 8) & 0xFF;
          int currB = image.pixels[imageIndex] & 0xFF;
         
          int col = image.pixels[imageIndex];
          float alpha = pa.alpha(col);
         
          int reflectImageIndex = (image.height-y-1) * image.width+x;
         
          //TOD clamp 0-255, map 0-255, 255- y*y * x
//          copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*0.8));
//          copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y * (0.005f*y) * 0.5));
//          copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(Tools3D.clamp(255 - y*y , 0, 255)));
//          copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*y*y * (0.00003f) - 20)); //WORKS
          if (alpha <= 0.0f){
            copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , 0.0f);
          }else{
            copyOfImage.pixels[reflectImageIndex] = pa.color(currR , currG , currB , Math.round(y*y*y * (0.00003f) - 60)); //WORKS 
          }
      }
    }
    copyOfImage.updatePixels();
    return copyOfImage;
  }
View Full Code Here

 
  private void loadNewPuzzle(String imageName, int horizontalTiles, int verticalTiles){
    for (MTComponent c : puzzleGroup.getChildren()){
      c.destroy();
    }
    PImage p = getMTApplication().loadImage(imagesPath + imageName);
    AbstractShape[] tiles = pf.createTiles(p, this.horizontalTiles, this.verticalTiles);
    for (int i = 0; i < tiles.length; i++) {
      final AbstractShape sh = tiles[i];
      //Delay to smooth the animation because of loading hickups
      final float x = ToolsMath.getRandom(0, MT4jSettings.getInstance().getWindowWidth());
View Full Code Here

    //Button for foto search
    final MTImageButton fotoButton;
//    PImage fotoButtonImg = p.loadImage(System.getProperty("user.dir")+File.separator + "examples"+  File.separator +"advanced"+ File.separator+ File.separator +"modestMapsMT"+ File.separator +  File.separator + "data"+ File.separator +
//        "foto6.png");
    //Load image from classpath
    PImage fotoButtonImg = p.loadImage( "advanced" + MTApplication.separator + "modestMapsMT" + MTApplication.separator + "data" + MTApplication.separator +
    "foto6.png");
    fotoButtonImg.resize((int)(fotoButtonImg.width/1.5f), (int)(fotoButtonImg.height/1.5f));
    fotoButton = new MTImageButton(fotoButtonImg, p);
    fotoButton.setName("fotoButton");
    fotoButton.setNoStroke(true);
    fotoButton.setDepthBufferDisabled(true); //Draw on top of everything
//    fotoButton.translate(new Vector3D(MT4jSettings.getInstance().getScreenWidth() - fotoButton.getWidthXY(TransformSpace.RELATIVE_TO_PARENT) -5, MT4jSettings.getInstance().getScreenHeight()- fotoButton.getHeightXY(TransformSpace.RELATIVE_TO_PARENT) -5, 0));
View Full Code Here

    textField.setText("Scene 3");
    this.getCanvas().addChild(textField);
    textField.setPositionGlobal(new Vector3D(mtApplication.width/2f, mtApplication.height/2f));
   
    //Button to return to the previous scene
    PImage arrow = mtApplication.loadImage(imagePath + "arrowRight.png");
    MTImageButton previousSceneButton = new MTImageButton(arrow, mtApplication);
    previousSceneButton.setNoStroke(true);
    if (MT4jSettings.getInstance().isOpenGlMode())
      previousSceneButton.setUseDirectGL(true);
    previousSceneButton.addActionListener(new ActionListener() {
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.