Background Image cause Latency on VST

Hello everyone and I am sorry if this topics is already solved.
I would like to know how can I load a background image juste one time at the beginning because I call repaint a lot of time in my programm and I finally have some latency due to the loading of my image. Thank you !

1 Like

For that purpose there is the ImageCache. Every Image has it’s pixel data shared, so that it is only loaded once, and the cache holds it until memory becomes scarce. So there is no need for you to hold an extra instance of the image (and even if you do, it will still share the memory), so that it doesn’t create any overhead.

The static getFromFile() will read an image file (and use the filename as access hash), and the getFromMemory() allows to read from the BinaryData, if you have the file baked into the binary via Projucer.

Oh yes ! that’s work ! thank you !

i don’t know image cache (yet) but i personally solve this by drawing onto an Image object in resized instead of paint, then in paint only redraw the finished image

1 Like