本文整理汇总了C++中OutStream::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ OutStream::Open方法的具体用法?C++ OutStream::Open怎么用?C++ OutStream::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutStream
的用法示例。
在下文中一共展示了OutStream::Open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prep_subimage
bool
DPXOutput::open (const std::string &name, const ImageSpec &userspec,
OpenMode mode)
{
if (mode == Create) {
m_subimage = 0;
if (m_subimage_specs.size() < 1) {
m_subimage_specs.resize (1);
m_subimage_specs[0] = userspec;
m_subimages_to_write = 1;
}
} else if (mode == AppendSubimage) {
if (m_write_pending)
write_buffer ();
++m_subimage;
if (m_subimage >= m_subimages_to_write) {
error ("Exceeded the pre-declared number of subimages (%d)",
m_subimages_to_write);
return false;
}
return prep_subimage (m_subimage, true);
// Nothing else to do, the header taken care of when we opened with
// Create.
} else if (mode == AppendMIPLevel) {
error ("DPX does not support MIP-maps");
return false;
}
// From here out, all the heavy lifting is done for Create
ASSERT (mode == Create);
if (is_opened())
close (); // Close any already-opened file
m_stream = new OutStream();
if (! m_stream->Open(name.c_str ())) {
error ("Could not open file \"%s\"", name.c_str ());
return false;
}
m_dpx.SetOutStream (m_stream);
m_dpx.Start ();
m_subimage = 0;
ImageSpec &m_spec (m_subimage_specs[m_subimage]); // alias the spec
// Check for things this format doesn't support
if (m_spec.width < 1 || m_spec.height < 1) {
error ("Image resolution must be at least 1x1, you asked for %d x %d",
m_spec.width, m_spec.height);
return false;
}
if (m_spec.depth < 1)
m_spec.depth = 1;
else if (m_spec.depth > 1) {
error ("DPX does not support volume images (depth > 1)");
return false;
}
// some metadata
std::string software = m_spec.get_string_attribute ("Software", "");
std::string project = m_spec.get_string_attribute ("DocumentName", "");
std::string copyright = m_spec.get_string_attribute ("Copyright", "");
std::string datestr = m_spec.get_string_attribute ("DateTime", "");
if (datestr.size () >= 19) {
// libdpx's date/time format is pretty close to OIIO's (libdpx uses
// %Y:%m:%d:%H:%M:%S%Z)
// NOTE: the following code relies on the DateTime attribute being properly
// formatted!
// assume UTC for simplicity's sake, fix it if someone complains
datestr[10] = ':';
datestr.replace (19, -1, "Z");
}
// check if the client wants endianness reverse to native
// assume big endian per Jeremy's request, unless little endian is
// explicitly specified
std::string endian = m_spec.get_string_attribute ("oiio:Endian", littleendian() ? "little" : "big");
m_wantSwap = (littleendian() != Strutil::iequals (endian, "little"));
m_dpx.SetFileInfo (name.c_str (), // filename
datestr.c_str (), // cr. date
software.empty () ? OIIO_INTRO_STRING : software.c_str (), // creator
project.empty () ? NULL : project.c_str (), // project
copyright.empty () ? NULL : copyright.c_str (), // copyright
m_spec.get_int_attribute ("dpx:EncryptKey", ~0), // encryption key
m_wantSwap);
// image info
m_dpx.SetImageInfo (m_spec.width, m_spec.height);
for (int s = 0; s < m_subimages_to_write; ++s) {
prep_subimage (s, false);
m_dpx.header.SetBitDepth (s, m_bitdepth);
ImageSpec &spec (m_subimage_specs[s]);
bool datasign = (spec.format == TypeDesc::INT8 ||
spec.format == TypeDesc::INT16);
m_dpx.SetElement (s, m_desc, m_bitdepth, m_transfer, m_cmetr,
m_packing, dpx::kNone, datasign,
spec.get_int_attribute ("dpx:LowData", 0xFFFFFFFF),
spec.get_float_attribute ("dpx:LowQuantity", std::numeric_limits<float>::quiet_NaN()),
//.........这里部分代码省略.........
示例2: if
bool
DPXOutput::open (const std::string &name, const ImageSpec &userspec,
OpenMode mode)
{
close (); // Close any already-opened file
if (mode != Create) {
error ("%s does not support subimages or MIP levels", format_name());
return false;
}
m_spec = userspec; // Stash the spec
// open the image
m_stream = new OutStream();
if (! m_stream->Open(name.c_str ())) {
error ("Could not open file \"%s\"", name.c_str ());
return false;
}
// Check for things this format doesn't support
if (m_spec.width < 1 || m_spec.height < 1) {
error ("Image resolution must be at least 1x1, you asked for %d x %d",
m_spec.width, m_spec.height);
return false;
}
if (m_spec.depth < 1)
m_spec.depth = 1;
else if (m_spec.depth > 1) {
error ("DPX does not support volume images (depth > 1)");
return false;
}
if (m_spec.format == TypeDesc::UINT8
|| m_spec.format == TypeDesc::INT8)
m_datasize = dpx::kByte;
else if (m_spec.format == TypeDesc::UINT16
|| m_spec.format == TypeDesc::INT16)
m_datasize = dpx::kWord;
else if (m_spec.format == TypeDesc::FLOAT
|| m_spec.format == TypeDesc::HALF) {
m_spec.format = TypeDesc::FLOAT;
m_datasize = dpx::kFloat;
} else if (m_spec.format == TypeDesc::DOUBLE)
m_datasize = dpx::kDouble;
else {
// use 16-bit unsigned integers as a failsafe
m_spec.format = TypeDesc::UINT16;
m_datasize = dpx::kWord;
}
// check if the client is giving us raw data to write
m_wantRaw = m_spec.get_int_attribute ("dpx:RawData", 0) != 0;
// check if the client wants endianness reverse to native
// assume big endian per Jeremy's request, unless little endian is
// explicitly specified
std::string tmpstr = m_spec.get_string_attribute ("oiio:Endian", littleendian() ? "little" : "big");
m_wantSwap = (littleendian() != Strutil::iequals (tmpstr, "little"));
m_dpx.SetOutStream (m_stream);
// start out the file
m_dpx.Start ();
// some metadata
std::string project = m_spec.get_string_attribute ("DocumentName", "");
std::string copyright = m_spec.get_string_attribute ("Copyright", "");
tmpstr = m_spec.get_string_attribute ("DateTime", "");
if (tmpstr.size () >= 19) {
// libdpx's date/time format is pretty close to OIIO's (libdpx uses
// %Y:%m:%d:%H:%M:%S%Z)
// NOTE: the following code relies on the DateTime attribute being properly
// formatted!
// assume UTC for simplicity's sake, fix it if someone complains
tmpstr[10] = ':';
tmpstr.replace (19, -1, "Z");
}
m_dpx.SetFileInfo (name.c_str (), // filename
tmpstr.c_str (), // cr. date
OIIO_INTRO_STRING, // creator
project.empty () ? NULL : project.c_str (), // project
copyright.empty () ? NULL : copyright.c_str (), // copyright
m_spec.get_int_attribute ("dpx:EncryptKey", ~0), // encryption key
m_wantSwap);
// image info
m_dpx.SetImageInfo (m_spec.width, m_spec.height);
// determine descriptor
m_desc = get_descriptor_from_string
(m_spec.get_string_attribute ("dpx:ImageDescriptor", ""));
// transfer function
dpx::Characteristic transfer;
std::string colorspace = m_spec.get_string_attribute ("oiio:ColorSpace", "");
if (Strutil::iequals (colorspace, "Linear")) transfer = dpx::kLinear;
else if (Strutil::iequals (colorspace, "GammaCorrected")) transfer = dpx::kUserDefined;
//.........这里部分代码省略.........
示例3: if
bool
DPXOutput::open (const std::string &name, const ImageSpec &userspec,
OpenMode mode)
{
close (); // Close any already-opened file
if (mode != Create) {
error ("%s does not support subimages or MIP levels", format_name());
return false;
}
m_spec = userspec; // Stash the spec
// open the image
m_stream = new OutStream();
if (! m_stream->Open(name.c_str ())) {
error ("Could not open file \"%s\"", name.c_str ());
return false;
}
// Check for things this format doesn't support
if (m_spec.width < 1 || m_spec.height < 1) {
error ("Image resolution must be at least 1x1, you asked for %d x %d",
m_spec.width, m_spec.height);
return false;
}
if (m_spec.depth < 1)
m_spec.depth = 1;
else if (m_spec.depth > 1) {
error ("DPX does not support volume images (depth > 1)");
return false;
}
if (m_spec.format == TypeDesc::UINT8
|| m_spec.format == TypeDesc::INT8)
m_datasize = dpx::kByte;
else if (m_spec.format == TypeDesc::UINT16
|| m_spec.format == TypeDesc::INT16)
m_datasize = dpx::kWord;
else if (m_spec.format == TypeDesc::FLOAT
|| m_spec.format == TypeDesc::HALF) {
m_spec.format = TypeDesc::FLOAT;
m_datasize = dpx::kFloat;
} else if (m_spec.format == TypeDesc::DOUBLE)
m_datasize = dpx::kDouble;
else {
// use 16-bit unsigned integers as a failsafe
m_spec.format = TypeDesc::UINT16;
m_datasize = dpx::kWord;
}
// check if the client is giving us raw data to write
m_wantRaw = m_spec.get_int_attribute ("dpx:RawData", 0) != 0;
m_dpx.SetOutStream (m_stream);
// start out the file
m_dpx.Start ();
// some metadata
std::string project = m_spec.get_string_attribute ("DocumentName", "");
std::string copyright = m_spec.get_string_attribute ("Copyright", "");
m_dpx.SetFileInfo (name.c_str (), // filename
NULL, // TODO: cr. date
OIIO_INTRO_STRING, // creator
project.empty () ? NULL : project.c_str (), // project
copyright.empty () ? NULL : copyright.c_str ()); // copyright
// image info
m_dpx.SetImageInfo (m_spec.width, m_spec.height);
// determine descriptor
m_desc = get_descriptor_from_string
(m_spec.get_string_attribute ("dpx:ImageDescriptor", ""));
// transfer function
dpx::Characteristic transfer;
std::string colorspace = m_spec.get_string_attribute ("oiio:ColorSpace", "");
if (iequals (colorspace, "Linear")) transfer = dpx::kLinear;
else if (iequals (colorspace, "GammaCorrected")) transfer = dpx::kUserDefined;
else if (iequals (colorspace, "Rec709")) transfer = dpx::kITUR709;
else if (iequals (colorspace, "KodakLog")) transfer = dpx::kLogarithmic;
else {
std::string dpxtransfer = m_spec.get_string_attribute ("dpx:Transfer", "");
transfer = get_characteristic_from_string (dpxtransfer);
}
// colorimetric
m_cmetr = get_characteristic_from_string
(m_spec.get_string_attribute ("dpx:Colorimetric", "User defined"));
// select packing method
dpx::Packing packing;
std::string tmpstr = m_spec.get_string_attribute ("dpx:ImagePacking", "Filled, method A");
if (iequals (tmpstr, "Packed"))
packing = dpx::kPacked;
else if (iequals (tmpstr, "Filled, method B"))
packing = dpx::kFilledMethodB;
//.........这里部分代码省略.........