Less 10 fps if i load many images

Hi guys, my sketch is very very slow. I think the problem is the several images loaded (188 images, on average 6 KB each one, 1784 x 870, .png, every images are pratically all trasparent). I solve this problem just write P2D in the size() but after some minutes passed, i see images go out of time. I think the problem is in the images, the frameRate with P2D is 60 while without P2D fps are less than 10. I post parts of my huge code just for show you where are my images:

PImage imgR1_1_1;
PImage imgR1_1_2;

void setup () {
  size (1784, 870, P2D);
  frameRate(fr);
  imgR1_1_1 = loadImage("Riquadro1.1.1.png");
  imgR1_1_2 = loadImage("Riquadro1.1.2.png");
}

void draw () {  

    if ((mll-prg1_3) - ((timer1)-prg1_3) >= secondi) { 
      timer1 = mll;
      Aa1 = random(1, 3);
      A1 = int(Aa1);
      Bb1 = random(1, 3);
      B1 = int(Bb1);
      BBbb1 = random(1, 3);
      BB1 = int(BBbb1);
    }


  if (A1 == 1) {
    if (B1 == 1) {
      if (mll - timer1 <= Is2) {  
        tint(255, 0);
        Radd1 = 0;
      } else {
        tint(255, 255-trah);
        Radd1 = ((((657 * perc) / 100) *  S1_1 ) / (secondi - Is2));
      }
      image(imgR1_1_1, 0, 0 + Radd1, width, width/prop);
    }


    if (B1 == 2) {
      if (mll - timer1 <= Is2) {  
        tint(255, 0);
        Radd1 = 0;
      } else {
        tint(255, 255-trah);
        Radd1 = ((((657 * perc) / 100) *  S1_1 ) / (secondi - Is2));
      }
      image(imgR1_1_2, 0, 0 + Radd1, width, width/prop);
    }
  }
Tagged:

Answers

  • image(imgR1_1_1, 0, 0 + Radd1, width, width/prop);

    If the image size is the same, you could load the iamge and resize it in setup instead of resizing them during the rendering. You can find out more about resize() under PImage in the reference.

    Kf

  • Tried but this isn't the bug

  • edited March 2018

    Yeah, please never use image() with 5 parameters

    Line 6 = ? comment that out

    Line 5 : try with two parameters or JAVA2D instead of P2D

  • With two parameters is a little better but the problem persists. JAVA2D doesn't solves nothing :-S Line 6 shows frameRate at 60

  • edited March 2018

    Line 6 shows frameRate at 60

    what does that mean?

      fill(0);
      text(int(frameRate), 18, 18);
    
  • I mean this

    int fr = 60; frameRate(fr);

  • 6 KB each one

    Compressed size means nothing

    1784 x 870, .png,

    Each image is converted to a PImage, one int per pixel. And you have 188 of these?

  •   Aa1 = random(1, 3);
      A1 = int(Aa1);
      Bb1 = random(1, 3);
      B1 = int(Bb1);
      BBbb1 = random(1, 3);
      BB1 = int(BBbb1);
    

    This is terrible

  • :( help me, what is the solution for images and why are terrible the last variables? :-SS

  • Do i have to delete every images?

Sign In or Register to comment.