Large numbers of or lots of megs of images

So I have an app that loading large number of local images. It’s loading and drawing around 600 PNG’s around 220mb that are map tiles. That all works and is pretty snappy.

The problems is when I load in the next bunch of images there are about 100 images that are bigger and are around 500mb total. I’m just loading them and not drawing them and it significantly impacts the performance of the app.

I’m running this on modern Mac Pro with 8 GB of ram.

Now i can probably load and unload these extra images as needed but i’d still like to know why loading a bunch of images is impacting performance? OF 0.062

does the app only slows down when loading?
You could try to swap the whole image loading process to another thread.
look into to threadedImageLoaderExample in OF to know how to do this.

hope this helped.

ben

Lots of times if you load lots of images but won’t be showing them all the time, it’s better to load your images and your textures separately.

an ofImage has both ofPixels which live in RAM and ofTexture which is another copy of the image data but lives on the graphics card and can be drawn to the screen. In general, your computer can have way more images with just ofPixels than with both textures and pixels since you have more ram than you have video memory.

by calling setUseTexture(false) on the ofImage before you load it, you’ll stop openFrameworks from uploading the pixels to the graphics card and save a lot of space.

For your tiles, you can create ofTextures separately and when you want to display a certain image in that tile call myTile.loadData( myImage.getPixels() ) and that ofTexture will then be able to draw that ofImage. loadData from pixels to texture is in general super fast. Way way faster than loading an image from disk into pixels on ram.

In general try to only have as many textures as you’re going to be drawing any give frame, that will keep your video memory usage to a minimum and keep things running happy and fast.

Hope this helps!