How to use settings() to resize the sketch to an image size

edited September 2015 in Using Processing

I need to use loadImage to get the image size and then pass the parameters to size. How to do this in PS3?

Answers

  • Thank you! So there is no way this would work?

    PImage source;       // Imagem original
    PImage destination;  // Imagem de destino
    int algoritmo = Dither.FLOYD_STEINBERG; //Determina o algoritmo
    Dither dither = new Dither(algoritmo); //Instancia o filtro
    int tempoTexto = (4 * 30) + 255;
    String texto = "";
    
    void settings(){
      source = loadImage("trabalho.png");
      size(source.width, source.height);
    }
    
  • edited September 2015 Answer ✓

    Inside settings() no way! Pay attention to the code examples from the link I've passed to ya! 3:-O

  • GoToLoop, thank you very much! It's working now, but this is not documented in the reference, right?

    I'll just post the code here for future references:

    PImage source;       // Imagem original
    PImage destination;  // Imagem de destino
    int algoritmo = Dither.FLOYD_STEINBERG; //Determina o algoritmo
    Dither dither = new Dither(algoritmo); //Instancia o filtro
    int tempoTexto = (4 * 30) + 255;
    String texto = "";
    
    void setup() {
      //Carrega a imagem original
      source = loadImage("trabalho.png");
      surface.setSize(source.width, source.height);
    
  • edited September 2015 Answer ✓

    Anything involving variable surface and the old frame is undocumented! :-&
    They had even protected surface's access level, dunno why! 8-}
    In order to access surface's outside its class, we need its getSurface()'s "getter"! X(

Sign In or Register to comment.