bool ofxImageSequence::loadSequence(string prefix, string filetype,  int startDigit, int endDigit, int numDigits)
{
	unloadSequence();

	char imagename[1024];
	stringstream format;
	int numFiles = endDigit - startDigit+1;
	if(numFiles <= 0 ){
		ofLogError("ofxImageSequence::loadSequence") << "No image files found.";
		return false;
	}

	if(numDigits != 0){
		format <<prefix<<"%0"<<numDigits<<"d."<<filetype;
	} else{
		format <<prefix<<"%d."<<filetype; 
	}
	
	for(int i = startDigit; i <= endDigit; i++){
		sprintf(imagename, format.str().c_str(), i);
		filenames.push_back(imagename);
		sequence.push_back(ofPixels());
		loadFailed.push_back(false);
	}
	
	loaded = true;
	
	lastFrameLoaded = -1;
	loadFrame(0);
	
	width  = sequence[0].getWidth();
	height = sequence[0].getHeight();
	return true;
}
bool ofxImageSequence::loadSequence(string _folder)
{
	unloadSequence();

	folderToLoad = _folder;

	if(useThread){
		threadLoader = new ofxImageSequenceLoader(this);
		return true;
	}

	if(preloadAllFilenames()){
		completeLoading();
		return true;
	}
	
	return false;

}
ofxImageSequence::~ofxImageSequence()
{
	if(loaded){
		unloadSequence();
	}
}
ofxImageSequence::~ofxImageSequence()
{
	unloadSequence();
}