Render a lot of same images

Is there a way to render a lot of same images fast?i made a array with 2 PImage objects…and rendering 2304 of them on the screen…with this i have 23-24 FPS on average…how can i(if possible) make this faster?thanks)

Reducing the original width and height of those images? How many do you want do draw? :slight_smile:

as much as screen width multiplied by screen height and this divided by 8…about reducing size…yea,that worked,thanks))also i found the FX2D renderer…this helped a lot too…

1920 * 1080 / 8 = 259200

That’s a lot of images! :slight_smile:

So you are drawing 8x8 px thumbnails? I guess then it would be good that the source images have that size too, unless you rotate them in which case it would be good that they are at least twice as large.

Another approach which I haven’t tried would be to load an image that already has such a grid of thumbnails and then you use image.copy() to copy little parts of that image on to the main screen. No idea if this is faster, but at least you would be working with just one (or a few) images instead of thousands of them. This technique is used in websites to avoid making tons of requests to the server to load tiny images.

One more advanced approach would be to draw lots of rectangles using the same texture() that contains all the thumbnails and then target different parts of that texture in different rectangles by setting the u, v coordinates in vertex().

What’s faster needs to be tested :slight_smile:

ps. Did you try both P2D and JAVA2D?

In my previous comment I didn’t focus on the “same” part of your question, thinking that they were different images.

For a grid of the same image covering the whole screen a texture also works:

PImage img;

float columns = 64.0;
float rows = 64.0;

void setup() {
  size(1000, 1000, P2D);
  img = loadImage("berlin-1.jpg");
  textureMode(NORMAL);
  textureWrap(REPEAT);
  noStroke();
}

void draw() {
  beginShape();
  texture(img);
  vertex(0, 0, 0, 0);
  vertex(width, 0, width/columns, 0);
  vertex(width, height, width/columns, height/rows);
  vertex(0, height, 0, height/rows);
  endShape();
}

Modified version of Examples > Topics > Textures > TextureQuad

With this approach the performance is not affected by the number of columns or rows.

P2D is definetly slower,tested this…about JAVA2D one sec…looks like its even faster than FX2D…at least test on 1046529(1023x1023 offscreen rendering) images showed these results…
FX2D - 9FPS average
JAVA2D - 35FPS average…

the “same” i mean some small amount pictures like picture1.png, picture2.png and picture3.png rendering a lot of times on different parts of the screen…

If you share a minimal example of your code then maybe someone can suggest something :slight_smile: