Help with understanding ofImage memory usage?

Hi so I’m starting work on what I’m calling a “game” that will use image sequences that are in a set grid. They’ll be merged together to create larger images/creatures/backgrounds, etc.

Here is an example where I was testing just the modular animation (this is not a program, it’s out of after effects):

The calculations that I’ve done is that I will have a 48 x 27 grid of 40px by 40px image “tiles” (some images will be multiple tiles, but one tile is 40 by 40). This is full HD 1920 x 1080 which my computer outputs via HDMI. With 1296 tiles comprising one frame of the program (some of the animations, which are multiple tiles have 100+ frames). In the past, I’ve just loaded all the imagery before the program starts and it was pretty painless (https://vimeo.com/74419288), but I’m imagining that I may butt heads with memory limitations.

My questions are (don’t need all of them answered necessarily):

  • when an image is “loaded” via OF, is it just the size of the actual image + some predictable amount of overhead?
  • is there a way to predict how long to some degree an ofImage will take to load if I know that they will only be black and white and some multiple of 40px by 40px?
  • can I dynamically load different images in the background without making the program lag? I imagine there will be different sets of tiles that will be needed at different times
  • maybe a more rudimentary question, is there a better way to see what is going on with my programs memory usage on a PC besides the system monitor?
  • should I be doing something else (40px by 40px videos maybe?)

I’m on a windows PC, with Windows 8, i7 I think quadcore (sorry my main laptop is currently being repaired hence the lack of specificity), 8GB of RAM, Nvidia graphics card

wow beautiful !
First limitation when loading ofImages will be video memory, cause textures are loaded and video memory gets full. You can use setUseTexture(false) to avoid texture loading. Only pixels get loaded in RAM, but you cannot draw them until you manually specify to load the texture on graphic card.
I don’t understand how you are using your grid of tiles, but 1920*1080 frame should take around 2MB memory
You can images in the background by using different threads, and OprenFrameworks can deal with this. Look at OfxThreadedImageLoader

How do you plan to make your modular animation working ?

Hey @benjaminshinobi that animation is very nice!
as for your questions

the use memory has nothing to do with the file size(because ti depends on the image file compression).
You can figure out the memory that’s going to use by multiplying width x height x bytesperpixel (usually 1 for grayscale, 3 for rgb and 4 for rgba)

[quote=“benjaminshinobi, post:1, topic:18820”]

  • is there a way to predict how long to some degree an ofImage will take to load if I know that they will only be black and white and some multiple of 40px by 40px?
    [/quote] I’d say no. It depends on the image compression, harddrive access speed, cpu speed, …
    If you want to load images fast, you might need to save them uncompressed and loadthem directly into the memory. I’ve done this before and it works, but I’d only recommend it if you need to use to much images that you cant load to ram. as said by talaron, before calling load call setUseTextureFalse(so you don’t load it to video memory).

[quote=“benjaminshinobi, post:1, topic:18820”]
black and white and some multiple of 40px by 40px?* can I dynamically load different images in the background without making the program lag? I imagine there will be different sets of tiles that will be needed at different times
[/quote] yes. se the threadedImageLoader example.

[quote=“benjaminshinobi, post:1, topic:18820”]

  • maybe a more rudimentary question, is there a better way to see what is going on with my programs memory usage on a PC besides the system monitor?
    [/quote] sure, usually IDEs (visual studio, code::blocks, xcode, etc) come with bundled tools to monitor memory usage and several other useful stuff.

[quote=“benjaminshinobi, post:1, topic:18820”]

  • should I be doing something else (40px by 40px videos maybe?)
    [/quote]yes, go to ofxAddons.com and check out the addons for using Sprites. There are several, some of those very well written. (I cant recall the names right now)
    best!

Thanks for the kind words guys!

I will look into the threaded image loader and sprites, I think this modular animation idea came from Super Nintendo programming which is based around tiles of set dimensions.

@talaron to answer your question (I think), there’s an effect in some early RPG’s where the tiles of the outside of a house will disappear revealing the inside which you can then walk into. I’m interested in using this as a kind of mechanic for the game. For example the character you play appears as a skeleton layer, muscle layer, skin layer and armor/clothing layer. You could change skin to an old man to fit in with a wizard community let’s say, or switch to better muscles to lift bigger objects.