コード例 #1
0
ファイル: frame.cpp プロジェクト: tomcodes/appleseed
bool Frame::write_image(
    const char*             file_path,
    const Image&            image,
    const ImageAttributes&  image_attributes) const
{
    assert(file_path);

    Image final_image(image);
    transform_to_output_color_space(final_image);

    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    try
    {
        try
        {
            GenericImageFileWriter writer;
            writer.write(file_path, final_image, image_attributes);
        }
        catch (const ExceptionUnsupportedFileFormat&)
        {
            const string extension = lower_case(filesystem::path(file_path).extension());

            RENDERER_LOG_ERROR(
                "file format '%s' not supported, writing the image in OpenEXR format "
                "(but keeping the filename unmodified).",
                extension.c_str());

            EXRImageFileWriter writer;
            writer.write(file_path, final_image, image_attributes);
        }
    }
    catch (const ExceptionIOError&)
    {
        RENDERER_LOG_ERROR(
            "failed to write image file %s: i/o error.",
            file_path);

        return false;
    }
    catch (const Exception& e)
    {
        RENDERER_LOG_ERROR(
            "failed to write image file %s: %s.",
            file_path,
            e.what());

        return false;
    }

    stopwatch.measure();

    RENDERER_LOG_INFO(
        "wrote image file %s in %s.",
        file_path,
        pretty_time(stopwatch.get_seconds()).c_str());

    return true;
}
コード例 #2
0
ファイル: frame.cpp プロジェクト: camargo/appleseed
bool Frame::archive(
    const char*         directory,
    char**              output_path) const
{
    assert(directory);

    // Construct the name of the image file.
    const string filename =
        "autosave." + get_time_stamp_string() + ".exr";

    // Construct the path to the image file.
    const string file_path = (filesystem::path(directory) / filename).string();

    // Return the path to the image file.
    if (output_path)
        *output_path = duplicate_string(file_path.c_str());

    Image transformed_image(*impl->m_image);
    transform_to_output_color_space(transformed_image);

    return
        write_image(
            file_path.c_str(),
            transformed_image,
            ImageAttributes::create_default_attributes());
}
コード例 #3
0
ファイル: frame.cpp プロジェクト: camargo/appleseed
void Frame::transform_to_output_color_space(Image& image) const
{
    const CanvasProperties& image_props = image.properties();

    for (size_t ty = 0; ty < image_props.m_tile_count_y; ++ty)
    {
        for (size_t tx = 0; tx < image_props.m_tile_count_x; ++tx)
            transform_to_output_color_space(image.tile(tx, ty));
    }
}
コード例 #4
0
ファイル: frame.cpp プロジェクト: camargo/appleseed
bool Frame::write_main_image(const char* file_path) const
{
    assert(file_path);

    Image transformed_image(*impl->m_image);
    transform_to_output_color_space(transformed_image);

    const ImageAttributes image_attributes =
        ImageAttributes::create_default_attributes();

    return write_image(file_path, transformed_image, image_attributes);
}