当前位置: 首页>>代码示例>>C++>>正文


C++ ImageCache类代码示例

本文整理汇总了C++中ImageCache的典型用法代码示例。如果您正苦于以下问题:C++ ImageCache类的具体用法?C++ ImageCache怎么用?C++ ImageCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ImageCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int
main (int argc, char *argv[])
{
    Timer alltimer;

    ImageSpec configspec;
    getargs (argc, argv, configspec);

    OIIO::attribute ("threads", nthreads);

    // N.B. This will apply to the default IC that any ImageBuf's get.
    ImageCache *ic = ImageCache::create ();  // get the shared one
    ic->attribute ("forcefloat", 1);   // Force float upon read
    ic->attribute ("max_memory_MB", 1024.0);  // 1 GB cache

    ImageBufAlgo::MakeTextureMode mode = ImageBufAlgo::MakeTxTexture;
    if (shadowmode)
        mode = ImageBufAlgo::MakeTxShadow;
    if (envlatlmode)
        mode = ImageBufAlgo::MakeTxEnvLatl;
    if (lightprobemode)
        mode = ImageBufAlgo::MakeTxEnvLatlFromLightProbe;
    bool ok = ImageBufAlgo::make_texture (mode, filenames[0],
                                          outputfilename, configspec,
                                          &std::cout);
    if (stats)
        std::cout << "\n" << ic->getstats();

    return ok ? 0 : EXIT_FAILURE;
}
开发者ID:Len3d,项目名称:oiio,代码行数:30,代码来源:maketx.cpp

示例2: main

int
main (int argc, char *argv[])
{
    getargs (argc, argv);

    if (! foreground_mode)
        Sysutil::put_in_background (argc, argv);

    // LG
//    Q_INIT_RESOURCE(iv);
    QApplication app(argc, argv);
    ImageViewer *mainWin = new ImageViewer;
    mainWin->show();

    // Set up the imagecache with parameters that make sense for iv
    ImageCache *imagecache = ImageCache::create (true);
    imagecache->attribute ("autotile", 256);

    // Make sure we are the top window with the focus.
    mainWin->raise ();
    mainWin->activateWindow ();

    // Add the images
    BOOST_FOREACH (const std::string &s, filenames) {
        mainWin->add_image (s);
    }
开发者ID:JamieFinch,项目名称:oiio,代码行数:26,代码来源:ivmain.cpp

示例3: main

int
main (int argc, char *argv[])
{
    Timer alltimer;
    getargs (argc, argv);

    if (stats) {
        ImageCache *ic = ImageCache::create ();  // get the shared one
        ic->attribute ("forcefloat", 1);   // Force float upon read
        ic->attribute ("max_memory_MB", 1024.0);  // 1 GB cache
        // N.B. This will apply to the default IC that any ImageBuf's get.
    }

    if (mipmapmode) {
        make_texturemap ("texture map");
    } else if (shadowmode) {
        make_texturemap ("shadow map");
    } else if (shadowcubemode) {
        std::cerr << "Shadow cubes currently unsupported\n";
    } else if (volshadowmode) {
        std::cerr << "Volume shadows currently unsupported\n";
    } else if (envlatlmode) {
        make_texturemap ("latlong environment map");
    } else if (envcubemode) {
        std::cerr << "Environment cubes currently unsupported\n";
    } else if (lightprobemode) {
        std::cerr << "Light probes currently unsupported\n";
    } else if (vertcrossmode) {
        std::cerr << "Vertcross currently unsupported\n";
    } else if (latl2envcubemode) {
        std::cerr << "Latlong->cube conversion currently unsupported\n";
    }

    if (verbose || stats) {
        std::cout << "maketx Runtime statistics (seconds):\n";
        double alltime = alltimer();
        std::cout << Strutil::format ("  total runtime:   %5.2f\n", alltime);
        std::cout << Strutil::format ("  file read:       %5.2f\n", stat_readtime);
        std::cout << Strutil::format ("  file write:      %5.2f\n", stat_writetime);
        std::cout << Strutil::format ("  initial resize:  %5.2f\n", stat_resizetime);
        std::cout << Strutil::format ("  mip computation: %5.2f\n", stat_miptime);
        std::cout << Strutil::format ("  unaccounted:     %5.2f\n",
                                      alltime-stat_readtime-stat_writetime-stat_resizetime-stat_miptime);
        size_t kb = Sysutil::memory_used(true) / 1024;
        std::cout << Strutil::format ("maketx memory used: %5.1f MB\n",
                                      (double)kb/1024.0);
    }

    Filter2D::destroy (filter);

    if (stats) {
        ImageCache *ic = ImageCache::create ();  // get the shared one
        std::cout << "\n" << ic->getstats();
    }

    return 0;
}
开发者ID:elrond79,项目名称:oiio,代码行数:57,代码来源:maketx.cpp

示例4: test_open_with_config

void test_open_with_config ()
{
    // N.B. This function must run after ImageBuf_test_appbuffer, which
    // writes "A.tif".
    ImageCache *ic = ImageCache::create(false);
    ImageSpec config;
    config.attribute ("oiio:DebugOpenConfig!", 1);
    ImageBuf A ("A.tif", 0, 0, ic, &config);
    OIIO_CHECK_EQUAL (A.spec().get_int_attribute("oiio:DebugOpenConfig!",0), 42);
    ic->destroy (ic);
}
开发者ID:Vertexwahn,项目名称:appleseed-deps,代码行数:11,代码来源:imagebuf_test.cpp

示例5: createRectangle

    Image::Image(const std::string filelocation, float x, float y, float width, float height) {
        this->x = x;
        this->y = y;
        this->_width = width;
        this->_height = height;
        isImage = true;

        ImageCache *imageCache = ImageCache::getInstance();

        if(!imageCache->isCached(filelocation)) {
            imageCache->insertIntoCache(filelocation, ImageLoader::createPNG(filelocation));
        }
        _imageItem = imageCache->getFromCache(filelocation);

        createRectangle();
    }
开发者ID:Gerjo,项目名称:phantom,代码行数:16,代码来源:Image.cpp

示例6: RemoveCache

	static void RemoveCache(const std::wstring& key)
	{
		std::unordered_map<std::wstring, ImageCache*>::const_iterator iter = c_CacheMap.find(key);
		if (iter != c_CacheMap.end())
		{
			ImageCache* cache = (*iter).second;
			cache->Release();
			//LogDebugF(L"* REMOVE: key=%s, ref=%i", key.c_str(), cache->GetRef());

			if (cache->IsInvalid())
			{
				//LogDebugF(L"* EMPTY-ERASE: key=%s", key.c_str());
				c_CacheMap.erase(iter);
				delete cache;
			}
		}
	}
开发者ID:AlonTzarafi,项目名称:rainmeter,代码行数:17,代码来源:TintedImage.cpp

示例7: run

void MainMenuHandler::run(sf::RenderWindow& window) {
	ImageCache mainMenuImages;
	const sf::Image& logoImage = mainMenuImages.get(Path::findDataPath("graphics/logo.png"));

	// Entering main menu, no game should be running.
	GameHandler::instance.reset();

	// Make view that is as close to 640x480 as possible and centered.
	view = window.GetDefaultView();
	view.Zoom(std::min(view.GetRect().GetWidth() / 640, view.GetRect().GetHeight() / 480));
	view.SetCenter(view.GetHalfSize());
	window.SetView(view);

	window.SetFramerateLimit(30);

	// Position at the top of the window.
	sf::Sprite logoSprite(logoImage);
	logoSprite.SetCenter(logoImage.GetWidth() / 2, 0);
	logoSprite.SetPosition(window.GetView().GetRect().GetWidth() / 2, 1);

	// Build the main menu GUI.
	GUI::Container gui;
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("New game", 200, 100, 240, 50, boost::bind(&MainMenuHandler::startGame, this))));
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("Exit", 250, 170, 140, 50, boost::bind(&sf::RenderWindow::Close, boost::ref(window)))));

	menuClosed = false;
	while (window.IsOpened() && !menuClosed) {
		sf::Event e;
		if (window.GetEvent(e)) {
			if (gui.handleEvent(e, window)) {
				continue;
			}
			if (e.Type == sf::Event::Closed || (e.Type == sf::Event::KeyPressed && e.Key.Code == sf::Key::Escape)) {
				window.Close();
				continue;
			}
		} else {
			window.Clear(sf::Color(0xcc, 0x66, 0x33));
			window.Draw(logoSprite);
			gui.draw(window);
			window.Display();
		}
	}
}
开发者ID:Pumpuli,项目名称:PutkaRTS,代码行数:44,代码来源:MainMenuHandler.cpp

示例8: get_image_cache

Image * get_image_cache(const std::string & filename, int hot_x, int hot_y,
                        int act_x, int act_y, TransparentColor color)
{
    FileImage * image;
    ImageCache::const_iterator it = image_cache.find(filename);
    if (it == image_cache.end()) {
        image = new FileImage(filename, 0, 0, 0, 0, color);
        image->load();
        if (image->is_valid())
            image->flags |= Image::USED | Image::CACHED;
        else {
            delete image;
            image = NULL;
        }
        image_cache[filename] = image;
    } else {
        image = it->second;
    }
    return image;
}
开发者ID:devinvisible,项目名称:anaconda,代码行数:20,代码来源:image.cpp

示例9: main

int
main (int argc, char *argv[])
{
    Timer alltimer;

    // Globally force classic "C" locale, and turn off all formatting
    // internationalization, for the entire maketx application.
    std::locale::global (std::locale::classic());

    ImageSpec configspec;
    Filesystem::convert_native_arguments (argc, (const char **)argv);
    getargs (argc, argv, configspec);

    OIIO::attribute ("threads", nthreads);

    // N.B. This will apply to the default IC that any ImageBuf's get.
    ImageCache *ic = ImageCache::create ();  // get the shared one
    ic->attribute ("forcefloat", 1);   // Force float upon read
    ic->attribute ("max_memory_MB", 1024.0);  // 1 GB cache

    ImageBufAlgo::MakeTextureMode mode = ImageBufAlgo::MakeTxTexture;
    if (shadowmode)
        mode = ImageBufAlgo::MakeTxShadow;
    if (envlatlmode)
        mode = ImageBufAlgo::MakeTxEnvLatl;
    if (lightprobemode)
        mode = ImageBufAlgo::MakeTxEnvLatlFromLightProbe;
    if (bumpslopesmode)
        mode = ImageBufAlgo::MakeTxBumpWithSlopes;
    
    bool ok = ImageBufAlgo::make_texture (mode, filenames[0],
                                          outputfilename, configspec,
                                          &std::cout);
    if (runstats)
        std::cout << "\n" << ic->getstats();

    return ok ? 0 : EXIT_FAILURE;
}
开发者ID:Shootfast,项目名称:oiio,代码行数:38,代码来源:maketx.cpp

示例10:

    Particles::Particles(unsigned count, string texturename, Color color, float lifetime, float totalLifetime, float speed, Vector3 scale, Vector3 direction, float density, unsigned randomness) {
        this->count             = count;
        this->scale             = scale;
        this->direction         = direction;
        this->density           = density;
        this->lifetime          = lifetime;
        this->currentLifetime   = 0;
        this->totalLifetime     = totalLifetime;
        this->texture           = nullptr;
        this->color             = color;
        this->speed             = speed;
        this->randomness        = randomness + 1;
        this->randomnessHalf    = this->randomness / 2.0f;

        ImageCache *imagecache = ImageCache::getInstance();

        if(texturename != "") {
            if(!imagecache->isCached(texturename)) {
                imagecache->insertIntoCache(texturename, ImageLoader::createPNG(texturename));
            }

            this->texture = imagecache->getFromCache(texturename);
        }
    }
开发者ID:Gerjo,项目名称:phantom,代码行数:24,代码来源:Particles.cpp

示例11: main

int main()
{
    fl_register_images();

    g_WilFilePathName       = "";
    g_WorkingPathName       = "";

    g_MainWindow            = new MainWindow();
    g_SelectSettingWindow   = new SelectSettingWindow();
    g_AnimationSelectWindow = new AnimationSelectWindow();
    g_AboutWindow           = new AboutWindow();
    g_AttributeSelectWindow = new AttributeSelectWindow();
    g_AttributeGridWindow   = new AttributeSelectWindow();
    g_ProgressBarWindow     = new ProgressBarWindow();
    g_LayerEditorWindow     = new LayerEditorWindow();
    g_LayerBrowserWindow    = new LayerBrowserWindow();
    g_CropConfigureWindow   = new CropConfigureWindow();

    g_ImageCache.SetPath(".");

    g_MainWindow->ShowAll();
    return Fl::run();
}
开发者ID:etorth,项目名称:mir2x,代码行数:23,代码来源:main.cpp

示例12: main

int
main (int argc, char *argv[])
{
    Filesystem::convert_native_arguments (argc, (const char **)argv);
    getargs (argc, argv);

    if (! quiet)
        std::cout << "Comparing \"" << filenames[0]
                  << "\" and \"" << filenames[1] << "\"\n";

    // Create a private ImageCache so we can customize its cache size
    // and instruct it store everything internally as floats.
    ImageCache *imagecache = ImageCache::create (true);
    imagecache->attribute ("forcefloat", 1);
    if (sizeof(void *) == 4)  // 32 bit or 64?
        imagecache->attribute ("max_memory_MB", 512.0);
    else
        imagecache->attribute ("max_memory_MB", 2048.0);
    imagecache->attribute ("autotile", 256);
    // force a full diff, even for files tagged with the same
    // fingerprint, just in case some mistake has been made.
    imagecache->attribute ("deduplicate", 0);

    ImageBuf img0, img1;
    if (! read_input (filenames[0], img0, imagecache) ||
        ! read_input (filenames[1], img1, imagecache))
        return ErrFile;
//    ImageSpec spec0 = img0.spec();  // stash it

    int ret = ErrOK;
    for (int subimage = 0;  subimage < img0.nsubimages();  ++subimage) {
        if (subimage > 0 && !compareall)
            break;
        if (subimage >= img1.nsubimages())
            break;

        if (! read_input (filenames[0], img0, imagecache, subimage) ||
            ! read_input (filenames[1], img1, imagecache, subimage)) {
            std::cerr << "Failed to read subimage " << subimage << "\n";
            return ErrFile;
        }

        if (img0.nmiplevels() != img1.nmiplevels()) {
            if (! quiet)
                std::cout << "Files do not match in their number of MIPmap levels\n";
        }

        for (int m = 0;  m < img0.nmiplevels();  ++m) {
            if (m > 0 && !compareall)
                break;
            if (m > 0 && img0.nmiplevels() != img1.nmiplevels()) {
                std::cerr << "Files do not match in their number of MIPmap levels\n";
                ret = ErrDifferentSize;
                break;
            }

            if (! read_input (filenames[0], img0, imagecache, subimage, m) ||
                ! read_input (filenames[1], img1, imagecache, subimage, m))
                return ErrFile;

            if (img0.deep() != img1.deep()) {
                std::cerr << "One image contains deep data, the other does not\n";
                ret = ErrDifferentSize;
                break;
            }

            int npels = img0.spec().width * img0.spec().height * img0.spec().depth;
            if (npels == 0)
                npels = 1;    // Avoid divide by zero for 0x0 images
            ASSERT (img0.spec().format == TypeDesc::FLOAT);

            // Compare the two images.
            //
            ImageBufAlgo::CompareResults cr;
            ImageBufAlgo::compare (img0, img1, failthresh, warnthresh, cr);

            int yee_failures = 0;
            if (perceptual && ! img0.deep()) {
                ImageBufAlgo::CompareResults cr;
                yee_failures = ImageBufAlgo::compare_Yee (img0, img1, cr);
            }

            if (cr.nfail > (failpercent/100.0 * npels) || cr.maxerror > hardfail ||
                yee_failures > (failpercent/100.0 * npels)) {
                ret = ErrFail;
            } else if (cr.nwarn > (warnpercent/100.0 * npels) || cr.maxerror > hardwarn) {
                if (ret != ErrFail)
                    ret = ErrWarn;
            }

            // Print the report
            //
            if (verbose || (ret != ErrOK && !quiet)) {
                if (compareall)
                    print_subimage (img0, subimage, m);
                std::cout << "  Mean error = ";
                safe_double_print (cr.meanerror);
                std::cout << "  RMS error = ";
                safe_double_print (cr.rms_error);
                std::cout << "  Peak SNR = ";
//.........这里部分代码省略.........
开发者ID:Zorroa,项目名称:oiio,代码行数:101,代码来源:idiff.cpp

示例13: main

int
main (int argc, char *argv[])
{
    getargs (argc, argv);

    std::cout << "Comparing \"" << filenames[0] 
             << "\" and \"" << filenames[1] << "\"\n";

    // Create a private ImageCache so we can customize its cache size
    // and instruct it store everything internally as floats.
    ImageCache *imagecache = ImageCache::create (true);
    imagecache->attribute ("forcefloat", 1);
    if (sizeof(void *) == 4)  // 32 bit or 64?
        imagecache->attribute ("max_memory_MB", 512.0);
    else
        imagecache->attribute ("max_memory_MB", 2048.0);
    imagecache->attribute ("autotile", 256);
#ifdef DEBUG
    imagecache->attribute ("statistics:level", 2);
#endif

    ImageBuf img0, img1;
    if (! read_input (filenames[0], img0, imagecache) ||
        ! read_input (filenames[1], img1, imagecache))
        return ErrFile;
//    ImageSpec spec0 = img0.spec();  // stash it

    int ret = ErrOK;
    for (int subimage = 0;  subimage < img0.nsubimages();  ++subimage) {
        if (subimage > 0 && !compareall)
            break;
        if (subimage >= img1.nsubimages())
            break;

        if (compareall) {
            std::cout << "Subimage " << subimage << ": ";
            std::cout << img0.spec().width << " x " << img0.spec().height;
            if (img0.spec().depth > 1)
                std::cout << " x " << img0.spec().depth;
            std::cout << ", " << img0.spec().nchannels << " channel\n";
        }

        if (! read_input (filenames[0], img0, imagecache, subimage) ||
            ! read_input (filenames[1], img1, imagecache, subimage))
            return ErrFile;

        if (img0.nmiplevels() != img1.nmiplevels()) {
            std::cout << "Files do not match in their number of MIPmap levels\n";
        }

        for (int m = 0;  m < img0.nmiplevels();  ++m) {
            if (m > 0 && !compareall)
                break;
            if (m > 0 && img0.nmiplevels() != img1.nmiplevels()) {
                std::cout << "Files do not match in their number of MIPmap levels\n";
                ret = ErrDifferentSize;
                break;
            }

            if (! read_input (filenames[0], img0, imagecache, subimage, m) ||
                ! read_input (filenames[1], img1, imagecache, subimage, m))
                return ErrFile;

            if (compareall && img0.nmiplevels() > 1) {
                std::cout << " MIP level " << m << ": ";
                std::cout << img0.spec().width << " x " << img0.spec().height;
                if (img0.spec().depth > 1)
                    std::cout << " x " << img0.spec().depth;
                std::cout << ", " << img0.spec().nchannels << " channel\n";
            }

            // Compare the dimensions of the images.  Fail if they
            // aren't the same resolution and number of channels.  No
            // problem, though, if they aren't the same data type.
            if (! same_size (img0, img1)) {
                std::cout << "Images do not match in size: ";
                std::cout << "(" << img0.spec().width << "x" << img0.spec().height;
                if (img0.spec().depth > 1)
                    std::cout << "x" << img0.spec().depth;
                std::cout << "x" << img0.spec().nchannels << ")";
                std::cout << " versus ";
                std::cout << "(" << img1.spec().width << "x" << img1.spec().height;
                if (img1.spec().depth > 1)
                    std::cout << "x" << img1.spec().depth;
                std::cout << "x" << img1.spec().nchannels << ")\n";
                ret = ErrDifferentSize;
                break;
            }

            int npels = img0.spec().width * img0.spec().height * img0.spec().depth;
            ASSERT (img0.spec().format == TypeDesc::FLOAT);

            // Compare the two images.
            //
            ImageBufAlgo::CompareResults cr;
            ImageBufAlgo::compare (img0, img1, failthresh, warnthresh, cr);

            int yee_failures = 0;
            if (perceptual)
                yee_failures = ImageBufAlgo::compare_Yee (img0, img1);
//.........这里部分代码省略.........
开发者ID:400notout,项目名称:oiio,代码行数:101,代码来源:idiff.cpp

示例14: convert_file

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";
//.........这里部分代码省略.........
开发者ID:Nazg-Gul,项目名称:oiio,代码行数:101,代码来源:iconvert.cpp

示例15: getargs


//.........这里部分代码省略.........
        else if (dataformatname == "half")
            configspec.format = TypeDesc::HALF;
        else if (dataformatname == "float")
            configspec.format = TypeDesc::FLOAT;
        else if (dataformatname == "double")
            configspec.format = TypeDesc::DOUBLE;
        else {
            std::cerr << "maketx ERROR: unknown data format \"" << dataformatname << "\"\n";
            exit (EXIT_FAILURE);
        }
    }

    configspec.tile_width  = tile[0];
    configspec.tile_height = tile[1];
    configspec.tile_depth  = tile[2];
    configspec.attribute ("compression", compression);
    if (fovcot != 0.0f)
        configspec.attribute ("fovcot", fovcot);
    configspec.attribute ("planarconfig", separate ? "separate" : "contig");
    if (Mcam != Imath::M44f(0.0f))
        configspec.attribute ("worldtocamera", TypeMatrix, &Mcam);
    if (Mscr != Imath::M44f(0.0f))
        configspec.attribute ("worldtoscreen", TypeMatrix, &Mscr);
    std::string wrapmodes = (swrap.size() ? swrap : wrap) + ',' + 
                            (twrap.size() ? twrap : wrap);
    configspec.attribute ("wrapmodes", wrapmodes);

    configspec.attribute ("maketx:verbose", verbose);
    configspec.attribute ("maketx:runstats", runstats);
    configspec.attribute ("maketx:resize", doresize);
    configspec.attribute ("maketx:nomipmap", nomipmap);
    configspec.attribute ("maketx:updatemode", updatemode);
    configspec.attribute ("maketx:constant_color_detect", constant_color_detect);
    configspec.attribute ("maketx:monochrome_detect", monochrome_detect);
    configspec.attribute ("maketx:opaque_detect", opaque_detect);
    configspec.attribute ("maketx:compute_average", compute_average);
    configspec.attribute ("maketx:unpremult", unpremult);
    configspec.attribute ("maketx:incolorspace", incolorspace);
    configspec.attribute ("maketx:outcolorspace", outcolorspace);
    configspec.attribute ("maketx:colorconfig", colorconfigname);
    configspec.attribute ("maketx:checknan", checknan);
    configspec.attribute ("maketx:fixnan", fixnan);
    configspec.attribute ("maketx:set_full_to_pixels", set_full_to_pixels);
    configspec.attribute ("maketx:highlightcomp", (int)do_highlight_compensation);
    configspec.attribute ("maketx:sharpen", sharpen);
    if (filtername.size())
        configspec.attribute ("maketx:filtername", filtername);
    configspec.attribute ("maketx:nchannels", nchannels);
    configspec.attribute ("maketx:channelnames", channelnames);
    if (fileformatname.size())
        configspec.attribute ("maketx:fileformatname", fileformatname);
    configspec.attribute ("maketx:prman_metadata", prman_metadata);
    configspec.attribute ("maketx:oiio_options", oiio);
    configspec.attribute ("maketx:prman_options", prman);
    if (mipimages.size())
        configspec.attribute ("maketx:mipimages", Strutil::join(mipimages,";"));

    std::string cmdline = Strutil::format ("OpenImageIO %s : %s",
                                     OIIO_VERSION_STRING,
                                     command_line_string (argc, argv, sansattrib));
    configspec.attribute ("Software", cmdline);
    configspec.attribute ("maketx:full_command_line", cmdline);

    // Add user-specified string attributes
    for (size_t i = 0; i < string_attrib_names.size(); ++i) {
        configspec.attribute (string_attrib_names[i], string_attrib_values[i]);
    }

    // Add user-specified "any" attributes -- try to deduce the type
    for (size_t i = 0; i < any_attrib_names.size(); ++i) {
        string_view s = any_attrib_values[i];
        // Does it parse as an int (and nothing more?)
        int ival;
        if (Strutil::parse_int(s,ival)) {
            Strutil::skip_whitespace(s);
            if (! s.size()) {
                configspec.attribute (any_attrib_names[i], ival);
                continue;
            }
        }
        s = any_attrib_values[i];
        // Does it parse as a float (and nothing more?)
        float fval;
        if (Strutil::parse_float(s,fval)) {
            Strutil::skip_whitespace(s);
            if (! s.size()) {
                configspec.attribute (any_attrib_names[i], fval);
                continue;
            }
        }
        // OK, treat it like a string
        configspec.attribute (any_attrib_names[i], any_attrib_values[i]);
    }

    if (ignore_unassoc) {
        configspec.attribute ("maketx:ignore_unassoc", (int)ignore_unassoc);
        ImageCache *ic = ImageCache::create ();  // get the shared one
        ic->attribute ("unassociatedalpha", (int)ignore_unassoc);
    }
}
开发者ID:Shootfast,项目名称:oiio,代码行数:101,代码来源:maketx.cpp


注:本文中的ImageCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。