How to use a jpeg (or whatever file format) as a background;

Hi guys, here it another question about porting Processing sketches on Android How can I use .jpg (or others file format) as background for my apps? I tried using

PImage wallpaper;

void setup() {
size(displayWidth, displayHeight, OPENGL);
smooth();
wallpaper = loadImage("wallpaper.png");
}

void draw() {
wallpaper.resize(width, height);
background(wallpaper);
}

In this way the maximum fps that I get is about 3 or 4... I tried even to load image with image(wallpaper, 0, 0, width, height) instead of background, but it recreate the image only every 5-6 seconds... in Processing and Mac app it works, but not on Android...

I tried the same in Eclipse but got same results (even activating hardware acceleration in the Manifest).

Thanks to all ;)

Tagged:

Answers

  • Answer ✓

    I have moved this from Arduino forum :)

  • Ehm... it is for Android, not Arduino :D

  • edited November 2013

    It maybe because of the call to resize in draw I suggest you put it in setup like this

    PImage wallpaper;
    
    void setup() {
      size(displayWidth, displayHeight, OPENGL);
      smooth(); 
      wallpaper = loadImage("wallpaper.png");
      wallpaper.resize(width, height);
    }
    
    void draw() {
      background(wallpaper);
    }
    

    Ehm... it is for Android, not Arduino

    That is why I moved it.

  • Nothing to do, I got 4 fps and stretched background image :\

  • Strange that the image is stretched, as it should have been resized in setup(). Try displaying the image with image() instead of background().

  • edited November 2013

    I already tried with image() instead of background, and it refresh the background image only every 4-5 seconds... I resolved, for now, using a generative background done in Processing, I think that it is more beautiful :D ... maybe it is some code issues, it is so chaotic... I will fix it

Sign In or Register to comment.