本文整理汇总了C++中imf::Header::compression方法的典型用法代码示例。如果您正苦于以下问题:C++ Header::compression方法的具体用法?C++ Header::compression怎么用?C++ Header::compression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imf::Header
的用法示例。
在下文中一共展示了Header::compression方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fcExrTaskData
fcExrTaskData(const char *p, int w, int h, fcExrCompression compression)
: path(p), width(w), height(h), header(w, h)
{
switch (compression) {
case fcExrCompression::None: header.compression() = Imf::NO_COMPRESSION; break;
case fcExrCompression::RLE: header.compression() = Imf::RLE_COMPRESSION; break;
case fcExrCompression::ZipS: header.compression() = Imf::ZIPS_COMPRESSION; break;
case fcExrCompression::Zip: header.compression() = Imf::ZIP_COMPRESSION; break;
case fcExrCompression::PIZ: header.compression() = Imf::PIZ_COMPRESSION; break;
}
}
示例2: convertHeader
/** \brief Convert an OpenEXR header to our own header representation.
*
* \param exrHeader - input header
* \param header - output header
*/
void convertHeader(const Imf::Header& exrHeader, CqTexFileHeader& header)
{
// Set width, height
const Imath::Box2i& dataBox = exrHeader.dataWindow();
header.setWidth(dataBox.max.x - dataBox.min.x+1);
header.setHeight(dataBox.max.y - dataBox.min.y+1);
// display window
const Imath::Box2i& displayBox = exrHeader.displayWindow();
header.set<Attr::DisplayWindow>( SqImageRegion(
displayBox.max.x - displayBox.min.x,
displayBox.max.y - displayBox.min.y,
displayBox.min.x - dataBox.min.x,
displayBox.min.y - dataBox.min.y) );
// Set tiling information ?
// Aspect ratio
header.set<Attr::PixelAspectRatio>(exrHeader.pixelAspectRatio());
TqChannelNameMap channelNameMap;
// Convert channel representation
const Imf::ChannelList& exrChannels = exrHeader.channels();
CqChannelList& channels = header.channelList();
for(Imf::ChannelList::ConstIterator i = exrChannels.begin();
i != exrChannels.end(); ++i)
{
// use lower case names for channels; OpenEXR uses upper case.
std::string chanName = i.name();
std::transform(chanName.begin(), chanName.end(), chanName.begin(),
::tolower);
channelNameMap[chanName] = i.name();
channels.addChannel( SqChannelInfo(chanName,
channelTypeFromExr(i.channel().type)) );
}
header.set<Attr::ExrChannelNameMap>(channelNameMap);
channels.reorderChannels();
// Set compresssion type
header.set<Attr::Compression>(exrCompressionToString(exrHeader.compression()));
}
示例3: if
bool
OpenEXROutput::put_parameter (const std::string &name, TypeDesc type,
const void *data)
{
// Translate
std::string xname = name;
if (istarts_with (xname, "oiio:"))
return false;
else if (iequals(xname, "worldtocamera"))
xname = "worldToCamera";
else if (iequals(xname, "worldtoscreen"))
xname = "worldToNDC";
else if (iequals(xname, "DateTime"))
xname = "capDate";
else if (iequals(xname, "description") || iequals(xname, "ImageDescription"))
xname = "comments";
else if (iequals(xname, "Copyright"))
xname = "owner";
else if (iequals(xname, "PixelAspectRatio"))
xname = "pixelAspectRatio";
else if (iequals(xname, "ExposureTime"))
xname = "expTime";
else if (iequals(xname, "FNumber"))
xname = "aperture";
else if (istarts_with (xname, format_prefix))
xname = std::string (xname.begin()+format_prefix.size(), xname.end());
// std::cerr << "exr put '" << name << "' -> '" << xname << "'\n";
// Special cases
if (iequals(xname, "Compression") && type == TypeDesc::STRING) {
const char *str = *(char **)data;
m_header->compression() = Imf::ZIP_COMPRESSION; // Default
if (str) {
if (iequals (str, "none"))
m_header->compression() = Imf::NO_COMPRESSION;
else if (iequals (str, "deflate") || iequals (str, "zip"))
m_header->compression() = Imf::ZIP_COMPRESSION;
else if (iequals (str, "rle"))
m_header->compression() = Imf::RLE_COMPRESSION;
else if (iequals (str, "zips"))
m_header->compression() = Imf::ZIPS_COMPRESSION;
else if (iequals (str, "piz"))
m_header->compression() = Imf::PIZ_COMPRESSION;
else if (iequals (str, "pxr24"))
m_header->compression() = Imf::PXR24_COMPRESSION;
#ifdef IMF_B44_COMPRESSION
// The enum Imf::B44_COMPRESSION is not defined in older versions
// of OpenEXR, and there are no explicit version numbers in the
// headers. BUT this other related #define is present only in
// the newer version.
else if (iequals (str, "b44"))
m_header->compression() = Imf::B44_COMPRESSION;
else if (iequals (str, "b44a"))
m_header->compression() = Imf::B44A_COMPRESSION;
#endif
}
return true;
}
if (iequals (xname, "openexr:lineOrder") && type == TypeDesc::STRING) {
const char *str = *(char **)data;
m_header->lineOrder() = Imf::INCREASING_Y; // Default
if (str) {
if (iequals (str, "randomY"))
m_header->lineOrder() = Imf::RANDOM_Y;
else if (iequals (str, "decreasingY"))
m_header->lineOrder() = Imf::DECREASING_Y;
}
return true;
}
// Supress planarconfig!
if (iequals (xname, "planarconfig") || iequals (xname, "tiff:planarconfig"))
return true;
// General handling of attributes
// FIXME -- police this if we ever allow arrays
if (type == TypeDesc::INT || type == TypeDesc::UINT) {
m_header->insert (xname.c_str(), Imf::IntAttribute (*(int*)data));
return true;
}
if (type == TypeDesc::INT16) {
m_header->insert (xname.c_str(), Imf::IntAttribute (*(short*)data));
return true;
}
if (type == TypeDesc::UINT16) {
m_header->insert (xname.c_str(), Imf::IntAttribute (*(unsigned short*)data));
return true;
}
if (type == TypeDesc::FLOAT) {
m_header->insert (xname.c_str(), Imf::FloatAttribute (*(float*)data));
return true;
}
if (type == TypeDesc::HALF) {
m_header->insert (xname.c_str(), Imf::FloatAttribute ((float)*(half*)data));
return true;
}
if (type == TypeDesc::TypeMatrix) {
m_header->insert (xname.c_str(), Imf::M44fAttribute (*(Imath::M44f*)data));
//.........这里部分代码省略.........
示例4: fcExrFrameData
fcExrFrameData(const char *p, int w, int h)
: path(p), width(w), height(h), header(w, h)
{
header.compression() = Imf::ZIPS_COMPRESSION;
}
示例5: render_flipbook
bool render_flipbook( flipbook::flipbook_t *flip, node_t *n, int start, int end, bool mblur, int subsample)
{
render_cancelled = false;
signal_connection_t connection = flip->closed.connect( &cancel_render);
std::size_t mem_size = 0;
render_context_t new_context = document_t::Instance().composition().current_context();
new_context.mode = flipbook_render;
new_context.result_node = n;
new_context.subsample = subsample;
new_context.motion_blur_extra_samples = 0;
new_context.motion_blur_shutter_factor = mblur ? 1 : 0;
// recalc the domain, in case this is our first render
n->recursive_calc_domain( new_context);
image::image_t img( n->domain().size().x + 1, n->domain().size().y + 1);
for( int i = start; i <= end; ++i)
{
try
{
new_context.time = i;
renderer_t renderer( new_context, true);
renderer.render();
// find the amount of memory required to store a frame.
// not the most efficient way of doing it, but it's done only once.
if( mem_size == 0)
{
// copy the renderer result to our buffer
boost::gil::fill_pixels( boost::gil::view( img), image::pixel_t( 0, 0, 0, 0));
Imath::Box2i area( intersect( n->domain(), n->defined()));
if( !area.isEmpty())
{
boost::gil::copy_pixels( n->const_subimage_view( area),
boost::gil::subimage_view( boost::gil::view( img),
area.min.x - n->domain().min.x,
area.min.y - n->domain().min.y,
area.size().x + 1,
area.size().y + 1));
}
Imf::Header header = Imf::Header( renderer.domain().size().x + 1, renderer.domain().size().y + 1);
header.compression() = Imf::B44_COMPRESSION;
imageio::imf_null_ostream os;
imageio::write_half_rgb_exr( os, header, boost::gil::const_view( img));
mem_size = os.size();
std::cout << "Flipbook: frame size = " << mem_size / 1024 << " kb \n";
}
std::auto_ptr<imageio::imf_memory_ostream> os( new imageio::imf_memory_ostream( mem_size));
if( !os.get())
{
// out of memory
connection.disconnect();
return true;
}
// copy the renderer result to our buffer
boost::gil::fill_pixels( boost::gil::view( img), image::pixel_t( 0, 0, 0, 0));
Imath::Box2i area( intersect( n->domain(), n->defined()));
if( !area.isEmpty())
{
boost::gil::copy_pixels( n->const_subimage_view( area),
boost::gil::subimage_view( boost::gil::view( img),
area.min.x - n->domain().min.x,
area.min.y - n->domain().min.y,
area.size().x + 1,
area.size().y + 1));
}
Imf::Header header = Imf::Header( renderer.domain().size().x + 1, renderer.domain().size().y + 1);
header.compression() = Imf::B44_COMPRESSION;
imageio::write_half_rgb_exr( *os, header, boost::gil::const_view( img));
if( render_cancelled)
{
connection.disconnect();
return false;
}
flip->add_frame( os);
}
catch( ...)
{
// TODO: report out of memory here
// if we have any frame, then play
connection.disconnect();
return !flip->empty();
}
}
connection.disconnect();
//.........这里部分代码省略.........