本文整理汇总了C++中imf::Header::dataWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ Header::dataWindow方法的具体用法?C++ Header::dataWindow怎么用?C++ Header::dataWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imf::Header
的用法示例。
在下文中一共展示了Header::dataWindow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()));
}
示例2: if
bool
OpenEXRInput::open (const std::string &name, ImageSpec &newspec)
{
// Quick check to reject non-exr files
bool tiled;
if (! Imf::isOpenExrFile (name.c_str(), tiled))
return false;
m_spec = ImageSpec(); // Clear everything with default constructor
// Unless otherwise specified, exr files are assumed to be linear.
m_spec.attribute ("oiio:ColorSpace", "Linear");
try {
if (tiled) {
m_input_tiled = new Imf::TiledInputFile (name.c_str());
m_header = &(m_input_tiled->header());
} else {
m_input_scanline = new Imf::InputFile (name.c_str());
m_header = &(m_input_scanline->header());
}
}
catch (const std::exception &e) {
error ("OpenEXR exception: %s", e.what());
return false;
}
if (! m_input_scanline && ! m_input_tiled) {
error ("Unknown error opening EXR file");
return false;
}
Imath::Box2i datawindow = m_header->dataWindow();
m_spec.x = datawindow.min.x;
m_spec.y = datawindow.min.y;
m_spec.z = 0;
m_spec.width = datawindow.max.x - datawindow.min.x + 1;
m_spec.height = datawindow.max.y - datawindow.min.y + 1;
m_spec.depth = 1;
m_topwidth = m_spec.width; // Save top-level mipmap dimensions
m_topheight = m_spec.height;
Imath::Box2i displaywindow = m_header->displayWindow();
m_spec.full_x = displaywindow.min.x;
m_spec.full_y = displaywindow.min.y;
m_spec.full_z = 0;
m_spec.full_width = displaywindow.max.x - displaywindow.min.x + 1;
m_spec.full_height = displaywindow.max.y - displaywindow.min.y + 1;
m_spec.full_depth = 1;
if (tiled) {
m_spec.tile_width = m_input_tiled->tileXSize();
m_spec.tile_height = m_input_tiled->tileYSize();
} else {
m_spec.tile_width = 0;
m_spec.tile_height = 0;
}
m_spec.tile_depth = 1;
query_channels (); // also sets format
m_nsubimages = 1;
if (tiled) {
// FIXME: levelmode
m_levelmode = m_input_tiled->levelMode();
m_roundingmode = m_input_tiled->levelRoundingMode();
if (m_levelmode == Imf::MIPMAP_LEVELS) {
m_nmiplevels = m_input_tiled->numLevels();
m_spec.attribute ("openexr:roundingmode", m_roundingmode);
} else if (m_levelmode == Imf::RIPMAP_LEVELS) {
m_nmiplevels = std::max (m_input_tiled->numXLevels(),
m_input_tiled->numYLevels());
m_spec.attribute ("openexr:roundingmode", m_roundingmode);
} else {
m_nmiplevels = 1;
}
} else {
m_levelmode = Imf::ONE_LEVEL;
m_nmiplevels = 1;
}
const Imf::EnvmapAttribute *envmap;
envmap = m_header->findTypedAttribute<Imf::EnvmapAttribute>("envmap");
if (envmap) {
m_cubeface = (envmap->value() == Imf::ENVMAP_CUBE);
m_spec.attribute ("textureformat", m_cubeface ? "CubeFace Environment" : "LatLong Environment");
// OpenEXR conventions for env maps
if (! m_cubeface)
m_spec.attribute ("oiio:updirection", "y");
m_spec.attribute ("oiio:sampleborder", 1);
// FIXME - detect CubeFace Shadow?
} else {
m_cubeface = false;
if (tiled && m_levelmode == Imf::MIPMAP_LEVELS)
m_spec.attribute ("textureformat", "Plain Texture");
// FIXME - detect Shadow
}
const Imf::CompressionAttribute *compressattr;
compressattr = m_header->findTypedAttribute<Imf::CompressionAttribute>("compression");
if (compressattr) {
const char *comp = NULL;
switch (compressattr->value()) {
case Imf::NO_COMPRESSION : comp = "none"; break;
//.........这里部分代码省略.........
示例3: while
bool
OpenEXRInput::seek_subimage (int subimage, int miplevel, ImageSpec &newspec)
{
if (subimage < 0 || subimage >= m_nsubimages) // out of range
return false;
if (miplevel < 0 || miplevel >= m_nmiplevels) // out of range
return false;
m_subimage = subimage;
m_miplevel = miplevel;
if (miplevel == 0 && m_levelmode == Imf::ONE_LEVEL) {
newspec = m_spec;
return true;
}
// Compute the resolution of the requested mip level.
int w = m_topwidth, h = m_topheight;
if (m_levelmode == Imf::MIPMAP_LEVELS) {
while (miplevel--) {
if (m_roundingmode == Imf::ROUND_DOWN) {
w = w / 2;
h = h / 2;
} else {
w = (w + 1) / 2;
h = (h + 1) / 2;
}
w = std::max (1, w);
h = std::max (1, h);
}
} else if (m_levelmode == Imf::RIPMAP_LEVELS) {
// FIXME
} else {
ASSERT(0);
}
m_spec.width = w;
m_spec.height = h;
// N.B. OpenEXR doesn't support data and display windows per MIPmap
// level. So always take from the top level.
Imath::Box2i datawindow = m_header->dataWindow();
Imath::Box2i displaywindow = m_header->displayWindow();
m_spec.x = datawindow.min.x;
m_spec.y = datawindow.min.y;
if (miplevel == 0) {
m_spec.full_x = displaywindow.min.x;
m_spec.full_y = displaywindow.min.y;
m_spec.full_width = displaywindow.max.x - displaywindow.min.x + 1;
m_spec.full_height = displaywindow.max.y - displaywindow.min.y + 1;
} else {
m_spec.full_x = m_spec.x;
m_spec.full_y = m_spec.y;
m_spec.full_width = m_spec.width;
m_spec.full_height = m_spec.height;
}
if (m_cubeface) {
m_spec.full_width = w;
m_spec.full_height = w;
}
newspec = m_spec;
return true;
}