本文整理汇总了C++中ImageOutput::format_name方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageOutput::format_name方法的具体用法?C++ ImageOutput::format_name怎么用?C++ ImageOutput::format_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageOutput
的用法示例。
在下文中一共展示了ImageOutput::format_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ir
static int
output_file (int argc, const char *argv[])
{
ASSERT (argc == 2 && !strcmp(argv[0],"-o"));
std::string filename = argv[1];
if (! ot.curimg.get()) {
std::cerr << "oiiotool ERROR: -o " << filename << " did not have any current image to output.\n";
return 0;
}
if (ot.noclobber && Filesystem::exists(filename)) {
std::cerr << "oiiotool ERROR: Output file \"" << filename
<< "\" already exists, not overwriting.\n";
return 0;
}
if (ot.verbose)
std::cout << "Writing " << argv[1] << "\n";
ImageOutput *out = ImageOutput::create (filename.c_str());
if (! out) {
std::cerr << "oiiotool ERROR: " << geterror() << "\n";
return 0;
}
bool supports_displaywindow = out->supports ("displaywindow");
ot.read ();
ImageRecRef saveimg = ot.curimg;
ImageRecRef ir (ot.curimg);
if (! supports_displaywindow && ot.output_autocrop &&
(ir->spec()->x != ir->spec()->full_x ||
ir->spec()->y != ir->spec()->full_y ||
ir->spec()->width != ir->spec()->full_width ||
ir->spec()->height != ir->spec()->full_height)) {
const char *argv[] = { "croptofull" };
int action_croptofull (int argc, const char *argv[]); // forward decl
action_croptofull (1, argv);
ir = ot.curimg;
}
ImageOutput::OpenMode mode = ImageOutput::Create; // initial open
for (int s = 0, send = ir->subimages(); s < send; ++s) {
for (int m = 0, mend = ir->miplevels(s); m < mend; ++m) {
ImageSpec spec = *ir->spec(s,m);
adjust_output_options (spec, ot);
if (! out->open (filename, spec, mode)) {
std::cerr << "oiiotool ERROR: " << out->geterror() << "\n";
return 0;
}
if (! (*ir)(s,m).write (out)) {
std::cerr << "oiiotool ERROR: " << (*ir)(s,m).geterror() << "\n";
return 0;
}
if (mend > 1) {
if (out->supports("mipmap")) {
mode = ImageOutput::AppendMIPLevel; // for next level
} else if (out->supports("multiimage")) {
mode = ImageOutput::AppendSubimage;
} else {
std::cout << "oiiotool WARNING: " << out->format_name()
<< " does not support MIP-maps for "
<< filename << "\n";
break;
}
}
}
mode = ImageOutput::AppendSubimage; // for next subimage
if (send > 1 && ! out->supports("multiimage")) {
std::cout << "oiiotool WARNING: " << out->format_name()
<< " does not support multiple subimages for "
<< filename << "\n";
break;
}
}
out->close ();
delete out;
if (ot.output_adjust_time) {
std::string metadatatime = ir->spec(0,0)->get_string_attribute ("DateTime");
std::time_t in_time = ir->time();
if (! metadatatime.empty())
DateTime_to_time_t (metadatatime.c_str(), in_time);
boost::filesystem::last_write_time (filename, in_time);
}
ot.curimg = saveimg;
return 0;
}
示例2: ufilename
static bool
convert_file (const std::string &in_filename, const std::string &out_filename)
{
if (noclobber && Filesystem::exists(out_filename)) {
std::cerr << "iconvert ERROR: Output file already exists \""
<< out_filename << "\"\n";
return false;
}
if (verbose)
std::cout << "Converting " << in_filename << " to " << out_filename << "\n";
std::string tempname = out_filename;
if (tempname == in_filename) {
tempname = out_filename + ".tmp"
+ Filesystem::extension (out_filename);
}
// Find an ImageIO plugin that can open the input file, and open it.
ImageInput *in = ImageInput::open (in_filename.c_str());
if (! in) {
std::string err = geterror();
std::cerr << "iconvert ERROR: "
<< (err.length() ? err : Strutil::format("Could not open \"%s\"", in_filename))
<< "\n";
delete in;
return false;
}
ImageSpec inspec = in->spec();
std::string metadatatime = inspec.get_string_attribute ("DateTime");
// Find an ImageIO plugin that can open the output file, and open it
ImageOutput *out = ImageOutput::create (tempname.c_str());
if (! out) {
std::cerr
<< "iconvert ERROR: Could not find an ImageIO plugin to write \""
<< out_filename << "\" :" << geterror() << "\n";
delete in;
return false;
}
// In order to deal with formats that support subimages, but not
// subimage appending, we gather them all first.
std::vector<ImageSpec> subimagespecs;
if (out->supports("multiimage") && !out->supports("appendsubimage")) {
ImageCache *imagecache = ImageCache::create ();
int nsubimages = 0;
ustring ufilename (in_filename);
imagecache->get_image_info (ufilename, 0, 0, ustring("subimages"),
TypeDesc::TypeInt, &nsubimages);
if (nsubimages > 1) {
subimagespecs.resize (nsubimages);
for (int i = 0; i < nsubimages; ++i) {
ImageSpec inspec = *imagecache->imagespec (ufilename, i, 0,
true /*native*/);
subimagespecs[i] = inspec;
adjust_spec (in, out, inspec, subimagespecs[i]);
}
}
ImageCache::destroy (imagecache);
}
bool ok = true;
bool mip_to_subimage_warning = false;
for (int subimage = 0;
ok && in->seek_subimage(subimage,0,inspec);
++subimage) {
if (subimage > 0 && !out->supports ("multiimage")) {
std::cerr << "iconvert WARNING: " << out->format_name()
<< " does not support multiple subimages.\n";
std::cerr << "\tOnly the first subimage has been copied.\n";
break; // we're done
}
int miplevel = 0;
do {
// Copy the spec, with possible change in format
ImageSpec outspec = inspec;
bool nocopy = adjust_spec (in, out, inspec, outspec);
if (miplevel > 0) {
// Moving to next MIP level
ImageOutput::OpenMode mode;
if (out->supports ("mipmap"))
mode = ImageOutput::AppendMIPLevel;
else if (out->supports ("multiimage") &&
out->supports ("appendsubimage")) {
mode = ImageOutput::AppendSubimage; // use if we must
if (! mip_to_subimage_warning
&& strcmp(out->format_name(),"tiff")) {
std::cerr << "iconvert WARNING: " << out->format_name()
<< " does not support MIPmaps.\n";
std::cerr << "\tStoring the MIPmap levels in subimages.\n";
}
mip_to_subimage_warning = true;
} else {
std::cerr << "iconvert WARNING: " << out->format_name()
<< " does not support MIPmaps.\n";
std::cerr << "\tOnly the first level has been copied.\n";
//.........这里部分代码省略.........
示例3: geterror
static void
write_mipmap (ImageBuf &img, const ImageSpec &outspec_template,
std::string outputfilename, std::string outformat,
TypeDesc outputdatatype, bool mipmap)
{
ImageSpec outspec = outspec_template;
outspec.set_format (outputdatatype);
// Find an ImageIO plugin that can open the output file, and open it
Timer writetimer;
ImageOutput *out = ImageOutput::create (outformat.c_str());
if (! out) {
std::cerr
<< "maketx ERROR: Could not find an ImageIO plugin to write "
<< outformat << " files:" << geterror() << "\n";
exit (EXIT_FAILURE);
}
if (! out->supports ("tiles")) {
std::cerr << "maketx ERROR: \"" << outputfilename
<< "\" format does not support tiled images\n";
exit (EXIT_FAILURE);
}
if (mipmap && !out->supports ("multiimage") && !out->supports ("mipmap")) {
std::cerr << "maketx ERROR: \"" << outputfilename
<< "\" format does not support multires images\n";
exit (EXIT_FAILURE);
}
if (! mipmap && ! strcmp (out->format_name(), "openexr")) {
// Send hint to OpenEXR driver that we won't specify a MIPmap
outspec.attribute ("openexr:levelmode", 0 /* ONE_LEVEL */);
}
if (mipmap && ! strcmp (out->format_name(), "openexr")) {
outspec.attribute ("openexr:roundingmode", 0 /* ROUND_DOWN */);
}
// OpenEXR always uses border sampling for environment maps
if ((envlatlmode || envcubemode) &&
!strcmp(out->format_name(), "openexr")) {
src_samples_border = true;
outspec.attribute ("oiio:updirection", "y");
outspec.attribute ("oiio:sampleborder", 1);
}
if (envlatlmode && src_samples_border)
fix_latl_edges (img);
if (! out->open (outputfilename.c_str(), outspec)) {
std::cerr << "maketx ERROR: Could not open \"" << outputfilename
<< "\" : " << out->geterror() << "\n";
exit (EXIT_FAILURE);
}
// Write out the image
if (verbose) {
std::cout << " Writing file: " << outputfilename << std::endl;
std::cout << " Filter \"" << filter->name() << "\" width = "
<< filter->width() << "\n";
}
bool ok = true;
ok &= img.write (out);
stat_writetime += writetimer();
if (mipmap) { // Mipmap levels:
if (verbose)
std::cout << " Mipmapping...\n" << std::flush;
ImageBuf tmp;
ImageBuf *big = &img, *small = &tmp;
while (ok && (outspec.width > 1 || outspec.height > 1)) {
Timer miptimer;
// Resize a factor of two smaller
ImageSpec smallspec = outspec;
smallspec.width = big->spec().width;
smallspec.height = big->spec().height;
smallspec.depth = big->spec().depth;
if (smallspec.width > 1)
smallspec.width /= 2;
if (smallspec.height > 1)
smallspec.height /= 2;
smallspec.full_width = smallspec.width;
smallspec.full_height = smallspec.height;
smallspec.full_depth = smallspec.depth;
smallspec.set_format (TypeDesc::FLOAT);
small->alloc (smallspec); // Realocate with new size
if (filtername == "box" && filter->width() == 1.0f)
parallel_image (resize_block, small, big,
smallspec.x, smallspec.x+smallspec.width,
smallspec.y, smallspec.y+smallspec.height,
nthreads);
else
parallel_image (resize_block_HQ, small, big,
smallspec.x, smallspec.x+smallspec.width,
smallspec.y, smallspec.y+smallspec.height,
nthreads);
stat_miptime += miptimer();
outspec = smallspec;
outspec.set_format (outputdatatype);
//.........这里部分代码省略.........
示例4: src
//.........这里部分代码省略.........
ColorConfig::deleteColorProcessor(processor);
processor = NULL;
stat_colorconverttime += colorconverttimer();
}
// Force float for the sake of the ImageBuf math
dstspec.set_format (TypeDesc::FLOAT);
// Handle resize to power of two, if called for
if (configspec.get_int_attribute("maketx:resize") && ! shadowmode) {
dstspec.width = pow2roundup (dstspec.width);
dstspec.height = pow2roundup (dstspec.height);
dstspec.full_width = dstspec.width;
dstspec.full_height = dstspec.height;
}
bool do_resize = false;
// Resize if we're up-resing for pow2
if (dstspec.width != srcspec.width || dstspec.height != srcspec.height ||
dstspec.full_depth != srcspec.full_depth)
do_resize = true;
// resize if the original was a crop
if (orig_was_crop)
do_resize = true;
// resize if we're converting from non-border sampling to border sampling
// (converting TO an OpenEXR environment map).
if (envlatlmode &&
(Strutil::iequals(configspec.get_string_attribute("maketx:fileformatname"),"openexr") ||
Strutil::iends_with(outputfilename,".exr")))
do_resize = true;
if (do_resize && orig_was_overscan &&
out && !out->supports("displaywindow")) {
outstream << "maketx ERROR: format " << out->format_name()
<< " does not support separate display windows,\n"
<< " which is necessary when combining resizing"
<< " and an input image with overscan.";
return false;
}
std::string filtername = configspec.get_string_attribute ("maketx:filtername", "box");
Filter2D *filter = setup_filter (filtername);
if (! filter) {
outstream << "maketx ERROR: could not make filter '" << filtername << "\n";
return false;
}
Timer resizetimer;
ImageBuf dst ("temp", dstspec);
ImageBuf *toplevel = &dst; // Ptr to top level of mipmap
if (! do_resize) {
// Don't need to resize
if (dstspec.format == ccSrc->spec().format) {
// Even more special case, no format change -- just use
// the original copy.
toplevel = ccSrc;
} else {
ImageBufAlgo::parallel_image (boost::bind(copy_block,&dst,ccSrc,_1),
OIIO::get_roi(dstspec));
}
} else {
// Resize
if (verbose)
outstream << " Resizing image to " << dstspec.width
<< " x " << dstspec.height << std::endl;
if (filtername == "box" && filter->width() == 1.0f)