Get BinaryData in the loop

I have in Binaries many images, all of them I want to add to Array.
I know how to do it if I use it like this:
files.add(ImageFileFormat::loadFrom(BinaryData::img0_png, BinaryData::img0_pngSize));

But how can I do it from a for loop? Something in that way?

        for(auto a=0; a<=90; a++){
            auto name = "img" + String(a) + "_png";
            for (int i = 0; i < BinaryData::namedResourceListSize; ++i){
                auto namedResourse = BinaryData::namedResourceList [I];
                auto fileName = String::fromUTF8 (namedResourse);

                if ({
                   files.add(ImageFileFormat::loadFrom(namedResourse, size));

Is it a correct way? How can I get SIZE of binary?

No. There is not a function from ImageFileFormat which takes a resource name. But there is one that takes a pointer to the data and to the size. I think you want something more like this (untested):

for(auto imageIndex = 0; imageIndex <= 90; imageIndex++)
    const auto resourceName = "img" + String(imageIndex) + "_png";
    auto imageSize { 0 };
    const auto imageData { BinaryData::getNamedResource (resourceName, imageSize) };
    if (imageData != nullptr)
        files.add(ImageFileFormat::loadFrom(imageData, imageSize));
1 Like

Thank you!

Check out the end of the BinaryData.h file. The number of files is encoded there too:

for(auto imageIndex = 0; imageIndex < BinaryData::namedResourceListSize; imageIndex++)
1 Like