예제 #1
0
void DXTencoderApp::update()
{
    
    bool hasNewFrame = false;
        
    if( mMovie && isStarted){
        
        //scaledSize.x= 196;
        scaledSize.x=mMovie->getWidth();

        
        hasNewFrame = mMovie->stepForward();
        
        
        scaledSize.y = mMovie->getSize().y * scaledSize.x / mMovie->getSize().x;

        
        correctedSize = scaledSize;
        correctedSize.y = correctedSize.y  - (correctedSize.y % 4);

        
        mDxtCreator.w = correctedSize.x;
        mDxtCreator.h = correctedSize.y;
        
        
        mSurface = mMovie->getSurface();
        if (mSurface) {

            if (currentFrame == 0) {
                movieLoadedSetParameters();
                isStarted = true;
            }
            
            if(currentFrame  < endFrame){
                                
                
                scaledSurface = ip::resizeCopy(*mSurface, Area(0, 0, mMovie->getSize().x, mMovie->getSize().y), scaledSize);
                
//                // make a copy but crop some pixels.
                correctedSurface = Surface(correctedSize.x, correctedSize.y, true);
                correctedSurface.copyFrom(scaledSurface, Area(0,0,correctedSize.x,correctedSize.y));

                mDxtCreator.writePixels(correctedSurface.getData(),currentFrame);
                currentFrame++;
            }else if(currentFrame == endFrame){
                mDxtCreator.close();
                mMovie->stop();
                isStarted = false;


            }
            
            
            
        }    }
}
예제 #2
0
void QTimeIterApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'f' ) {
		setFullScreen( ! isFullScreen() );
	}
	else if( event.getChar() == 'o' ) {
		fs::path moviePath = getOpenFilePath();
		if( ! moviePath.empty() )
			loadMovieFile( moviePath );
	}
	
	// these keys only make sense if there is an active movie
	if( mMovie ) {
		if( event.getCode() == KeyEvent::KEY_LEFT ) {
			mMovie->stepBackward();
		}
		if( event.getCode() == KeyEvent::KEY_RIGHT ) {
			mMovie->stepForward();
		}
		else if( event.getChar() == 's' ) {
			if( mSurface ) {
				fs::path savePath = getSaveFilePath();
				if( ! savePath.empty() ) {
					writeImage( savePath, *mSurface );
				}
			}
		}
		else if( event.getChar() == 'm' ) {
			// jump to the middle frame
			mMovie->seekToTime( mMovie->getDuration() / 2 );
		}
		else if( event.getChar() == ' ' ) {
			if( mMovie->isPlaying() )
				mMovie->stop();
			else
				mMovie->play();
		}
	}
}