void hdr_writer_t::do_write_image( const boost::filesystem::path& p, const image::const_image_view_t& view, const adobe::dictionary_t& params) const { std::auto_ptr<OIIO::ImageOutput> out( OIIO::ImageOutput::create( filesystem::file_string( p))); if( !out.get()) throw exception( "Write HDR: Can't open output file"); OIIO::ImageSpec spec( view.width(), view.height(), 3, OIIO::TypeDesc::FLOAT); add_common_attributes( spec); if( !out->open( filesystem::file_string( p), spec)) throw exception( "Write HDR: Can't open output file"); char *pixels = (char *) boost::gil::interleaved_view_get_raw_data( view); std::size_t xstride = 4 * sizeof( float); std::size_t ystride = xstride * view.width(); if( !out->write_image( OIIO::TypeDesc::FLOAT, pixels, xstride, ystride, OIIO::AutoStride)) throw exception( "Write HDR: Can't write pixels"); if( !out->close()) throw exception( "Write HDR: Can't close file"); }
void tga_writer_t::do_write_image( const boost::filesystem::path& p, const image::const_image_view_t& view, const adobe::dictionary_t& params) const { int channels = adobe::get_value( params, adobe::name_t( "channels")).cast<int>(); int compress = adobe::get_value( params, adobe::name_t( "compress")).cast<int>(); std::auto_ptr<OIIO::ImageOutput> out( OIIO::ImageOutput::create( filesystem::file_string( p))); if( !out.get()) throw exception( "Write TGA: Can't open output file"); if( channels) channels = 3; else channels = 4; OIIO::ImageSpec spec( view.width(), view.height(), channels, OIIO::TypeDesc::UINT8); add_common_attributes( spec); switch( compress) { case none_compression: break; case rle_compression: spec.attribute( "compression", "rle"); break; default: throw unsupported_image( "unsupported compression"); } if( !out->open( filesystem::file_string( p), spec)) throw exception( "Can't open output file"); std::vector<image::pixel_t> scanline( view.width()); for( int y = 0; y < view.height(); ++y) { std::copy( view.row_begin( y), view.row_end( y), scanline.begin()); clamp( scanline.begin(), scanline.end()); if( !out->write_scanline( y, 0, OIIO::TypeDesc::FLOAT, (void *) &( *scanline.begin()), sizeof( image::pixel_t))) throw exception( "Write image: Can't write pixels"); } if( !out->close()) throw exception( "Write image: Can't close file"); }
logger::logger() { const configuration& conf = configuration::instance(); boost::log::register_simple_formatter_factory< boost::log::trivial::severity_level, char >("Severity"); add_common_attributes(); add_file_log(keywords::file_name = conf.get(configuration::LOG_DIR)->second + '/' + conf.get(configuration::LOG_FILE)->second, keywords::rotation_size = 10 * 1024 * 1024, keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), keywords::format = "<%Severity%> [%TimeStamp%]: %Message%", keywords::auto_flush = true ); string logLevel = conf.get(configuration::LOG_LEVEL)->second; if ("TRACE" == logLevel) { core::get()->set_filter(trivial::severity >= trivial::trace); } else if ("DEBUG" == logLevel) { core::get()->set_filter(trivial::severity >= trivial::debug); } else if ("INFO" == logLevel) { core::get()->set_filter(trivial::severity >= trivial::info); } else if ("WARNING" == logLevel) { core::get()->set_filter(trivial::severity >= trivial::warning); } else if ("ERROR" == logLevel) { core::get()->set_filter(trivial::severity >= trivial::error); } else if ("FATAL" == logLevel) { core::get()->set_filter(trivial::severity >= trivial::fatal); } else { core::get()->set_filter(trivial::severity >= trivial::info); } }
void png_writer_t::do_write_image( const boost::filesystem::path& p, const image::const_image_view_t& view, const core::dictionary_t& params) const { int channels = core::get<int>( params, core::name_t( "channels")); std::auto_ptr<OIIO::ImageOutput> out( OIIO::ImageOutput::create( filesystem::file_string( p))); if( !out.get()) throw exception( "Write PNG: Can't open output file"); if( channels) channels = 3; else channels = 4; OIIO::ImageSpec spec( view.width(), view.height(), channels, OIIO::TypeDesc::UINT8); add_common_attributes( spec); if( !out->open( filesystem::file_string( p), spec)) throw exception( "Can't open output file"); std::vector<image::pixel_t> scanline( view.width()); for( int y = 0; y < view.height(); ++y) { std::copy( view.row_begin( y), view.row_end( y), scanline.begin()); clamp( scanline.begin(), scanline.end()); if( !out->write_scanline( y, 0, OIIO::TypeDesc::FLOAT, (void *) &( *scanline.begin()), sizeof( image::pixel_t))) throw exception( "Write image: Can't write pixels"); } if( !out->close()) throw exception( "Write image: Can't close file"); }