Exemplo n.º 1
0
void THISSequence::recomputePreview()
{
    if(!loaded || !widthSet) {
        return;
    }

    framesToShow = (drawWidth / widthPerFrame);
    if(framesToShow == 0) {
        return;
    }
    int startIndex = getIndexAtPercent(drawRange.min);
    int endIndex = getIndexAtPercent(drawRange.max);
    int framesInRange = (endIndex - startIndex);

    heightPerFrame = (widthPerFrame/imageWidth) * imageHeight;

    int frameStep = framesInRange / framesToShow;
    int fameIndex = 0;

    clearPreviewTextures();

    for(int i = 0; i < framesToShow; i ++) {
        ofImage* thumbnail = frames[startIndex+frameStep*i]->getThumbnail();
        PreviewTexture p;
        p.frameIndex = startIndex+frameStep*i;
        p.texture = new ofTexture();
        p.texture->allocate(thumbnail->getWidth(), thumbnail->getHeight(), glTypeForImageType(imageType));
        p.texture->loadData(thumbnail->getPixels(), thumbnail->getWidth(), thumbnail->getHeight(), glTypeForImageType(imageType));
        p.bounds = ofRectangle(widthPerFrame*i, 0, widthPerFrame, heightPerFrame);


        previewTextures.push_back( p );
    }
}
Exemplo n.º 2
0
void ofxTLImageSequence::recomputePreview(){
	
	if(!loaded){
		ofLogError("ofxTLImageSequence -- hasn't been loaded");
		return;
	}
	
	if(bounds.height < 20){
		ofLogError("ofxTLImageSequence -- too squished at height " + ofToString(20));
		return;
	}
	
	float widthPerFrame = bounds.height/imageHeight * imageWidth;
	int framesToShow = (bounds.width / widthPerFrame) + 1;
	if(framesToShow == 0){
		ofLogError("ofxTLImageSequence -- no frames to show!");
		return;
	}
	
	
	int startIndex = getIndexAtPercent(zoomBounds.min);
	int endIndex = getIndexAtPercent(zoomBounds.max);
	int framesInRange = (endIndex - startIndex);

	int frameStep = framesInRange / framesToShow;
	int fameIndex = 0;
//	cout << " start index is " << startIndexDec << " end index " << endIndexDec << " frames in range " << framesInRange << " framestep " << frameStep << " frames to show " << framesToShow << endl;
	
	clearPreviewTextures();
	
	for(int i = 0; i < framesToShow; i++){
		ofImage* thumbnail = frames[startIndex+frameStep*i]->getThumbnail();
		PreviewTexture p;
		
		p.frameIndex = startIndex+frameStep*i;
		p.texture = new ofTexture();
		p.texture->allocate(thumbnail->getWidth(), thumbnail->getHeight(), ofGetGlInternalFormat(thumbnail->getPixelsRef()));
		p.texture->loadData(thumbnail->getPixels(), thumbnail->getWidth(), thumbnail->getHeight(), ofGetGlInternalFormat(thumbnail->getPixelsRef()));
		p.bounds = ofRectangle(widthPerFrame*i, 0, widthPerFrame, bounds.height);

//		cout << " preview texture for frame " << startIndex+framesInRange*i << endl;
		
		previewTextures.push_back( p );
	}	
}
Exemplo n.º 3
0
ofImage* THISSequence::getFrame(float percent, bool thumb)
{
    return getFrame(getIndexAtPercent(percent), thumb);
}