void ImageSequenceSource::loadImageSequence(const std::string& d) throw (tgt::FileException, std::bad_alloc) { if (!isInitialized()) { LERROR("loadImageSequence(): not initialized"); return; } // important: d might be cleared by clearSequence std::string dir(d); forceReload_ = false; if (!imageSequence_) { LERROR("No image sequence present"); return; } // clear current sequence clearSequence(); if (dir.empty()) return; LINFO("Loading images from directory " << dir << " ..."); currentDir_ = dir; imageDirectory_.set(dir); // load images as textures and collect them in an image sequence std::vector<std::string> filenames = tgt::FileSystem::readDirectory(dir, true, false); // create progress bar ProgressBar* progressDialog = 0; if (showProgressBar_.get() && !filenames.empty()) { progressDialog = VoreenApplication::app()->createProgressDialog(); if (progressDialog) { progressDialog->setTitle("Loading Images"); progressDialog->show(); progressDialog->setProgress(0.f); progressDialog->forceUpdate(); } } tgt::Texture::Filter filterMode = textureFiltering_.get() ? tgt::Texture::LINEAR : tgt::Texture::NEAREST; for (size_t i=0; i<filenames.size(); ++i) { if (progressDialog) { progressDialog->setMessage("Loading " + filenames[i] + " ..."); progressDialog->setProgress(static_cast<float>(i) / static_cast<float>(filenames.size())); } LINFO("Loading image " << filenames[i] << " ..."); tgt::Texture* texture = TexMgr.load(dir + "/" + filenames[i], filterMode, false, false, true, false, !GpuCaps.isNpotSupported()); if (texture) imageSequence_->add(texture); else LWARNING("Failed to load image: " << filenames[i]); } LGL_ERROR; // upload texture data if (uploadTextureData_.get()) { LINFO("Uploading texture data ..."); for (unsigned int i=0; i<imageSequence_->size(); i++) imageSequence_->at(i)->uploadTexture(); LGL_ERROR; } // clear progress if (progressDialog) { progressDialog->hide(); delete progressDialog; progressDialog = 0; } // output sequence outport_.setData(imageSequence_); LINFO("Successfully loaded " << imageSequence_->size() << " images."); numImages_.set(imageSequence_->size()); LGL_ERROR; }