bool CompressedImage::render(std::string filename, unsigned short numberOfIterations, float ratio)
{
    RasterImage output;
    std::vector<std::thread> threads;
    std::vector<Pixmap*> pixmaps(m_layers.size());

    RenderingParameters params = { numberOfIterations, ratio };

    //Render each layer concurrently
    for (unsigned int i = 0; i < m_layers.size(); ++i)
        threads.push_back(std::thread(&CompressedImage::renderingJob, this, std::ref(params), i, std::ref(pixmaps)));

    for (unsigned int i = 0; i < m_layers.size(); ++i)
    {
        threads[i].join();
        output.addLayer(pixmaps[i]);
    }

    return output.save(filename);
}