TEST_F(BitmapImageTest, destroyDecodedDataExceptCurrentFrame) { loadImage("/tests/fast/images/resources/animated-10color.gif"); size_t totalSize = decodedSize(); size_t frame = frameCount() / 2; setCurrentFrame(frame); size_t size = frameDecodedSize(frame); destroyDecodedData(false); EXPECT_LT(m_imageObserver.m_lastDecodedSizeChangedDelta, 0); EXPECT_GE(m_imageObserver.m_lastDecodedSizeChangedDelta, -static_cast<int>(totalSize - size)); }
void UndoTransaction::newFrame() { // add a new cel to every layer newFrameForLayer(m_sprite->getFolder(), m_sprite->getCurrentFrame()+1); // increment frames counter in the sprite setNumberOfFrames(m_sprite->getTotalFrames()+1); // go to next frame (the new one) setCurrentFrame(m_sprite->getCurrentFrame()+1); }
void ControllerAnnotations::setPlayerParameters(playerParameters* parameters) { auto model = static_cast<Annotations*>(getModel()); model->setCurrentFrame(parameters->m_CurrentFrameNumber); IController* ctr = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::TRACKEDCOMPONENTCORE); auto trackedComponentCoreController = qobject_cast<ControllerTrackedComponentCore*>(ctr); auto trackedTrajectoryModel = dynamic_cast<IModelTrackedTrajectory *>(trackedComponentCoreController->getModel()); if (trackedTrajectoryModel != nullptr) model->updateTrackedAnnotations(trackedTrajectoryModel->getChildNodes()); updateView(); }
//============================================================================= // toss // //============================================================================= void Bottle::toss(Entity *target) { setFrames(bottleNS::START_THROW_FRAME,bottleNS::END_THROW_FRAME); setCurrentFrame(bottleNS::START_THROW_FRAME); posVector = target->getPosition(); attackVector = target->getPosition() - D3DXVECTOR2(spriteData.x,spriteData.y);//get direction to fly; radVector = attackVector; velocity = velocity = normalize(attackVector)*bottleNS::AIR_SPEED; visible = true; active = true; }
void Sprite::updateAnimations() { if (!m_animations.empty() && m_isAnimated) { if(m_currentAnimation >= m_animations.size()) { throw EXCEPTION("Trying to play inexistant animation:", m_currentAnimation, "| Animations:", m_animations.size()); } m_animations.at(m_currentAnimation).play(); setPosition(m_animations.at(m_currentAnimation).currentPosition().x, m_animations.at(m_currentAnimation).currentPosition().y); setCurrentFrame(m_animations.at(m_currentAnimation).currentFrame()); } }
void OverviewWidget::renderPreviews() { if(autoPreview_) { if (renderPort_) { int currentFrame = currentFrame_; if (!previews_.empty()) { for (size_t vs = 0; vs < previews_.size(); vs++) { overviewScene_->removeItem(previews_.at(vs)); } } previews_.clear(); int quadSize = 40; int stepLength = duration_ / quadSize; if (stepLength < quadSize) stepLength = quadSize; // save the current settings tgt::ivec2 size = renderPort_->getSize(); renderPort_->resize(tgt::ivec2(quadSize,quadSize)); QPixmap previewPixmap; QImage* preview = 0; for (int i = 0; i < duration_ - 1; i += stepLength) { preview = new QImage(QSize(quadSize,quadSize), QImage::Format_ARGB32); emit currentFrameChanged(i); networkEvaluator_->process(); tgt::col4* buffer = renderPort_->readColorBuffer<uint8_t>(); // TODO: catch exceptions for (int x = quadSize-1; x >= 0; x-=1) { for (int y = 0; y < quadSize; y+=1) { QColor color(buffer->r, buffer->g, buffer->b, 255); QRgb rgba = color.rgba(); preview->setPixel(x,y, rgba); buffer++; } } const QImage img = preview->copy(0,0, quadSize,quadSize); previewPixmap = QPixmap::fromImage(img); QGraphicsPixmapItem* pixmapItem = overviewScene_->addPixmap(previewPixmap); previews_.push_back(pixmapItem); pixmapItem->moveBy(i, 26); pixmapItem->setZValue(-1); } delete preview; renderPort_->resize(size); setCurrentFrame(currentFrame); emit currentFrameChanged(currentFrame); } } }
TEST_F(BitmapImageDeferredDecodingTest, correctDecodedDataSize) { // When deferred decoding is enabled, requesting any one frame shouldn't // result in decoding any other frames. loadImage("/LayoutTests/fast/images/resources/anim_none.gif", false); frameAtIndex(1); int frameSize = static_cast<int>(m_image->size().area() * sizeof(ImageFrame::PixelData)); EXPECT_EQ(frameSize, m_imageObserver->m_lastDecodedSizeChangedDelta); frameAtIndex(0); // Trying to destroy all data except an undecoded frame should go ahead and // destroy all other frames. setCurrentFrame(2); destroyDecodedData(false); EXPECT_EQ(-frameSize * 2, m_imageObserver->m_lastDecodedSizeChangedDelta); }
void Animation::stop() { if (!isPlaying()) { return; } // Clean up the last frame that was drawn before stopping markDirtyRect(_vm->_screen->getSurface()); setPlaying(false); // Reset the animation to the beginning setCurrentFrame(0); clearShift(); debugC(3, kDraciAnimationDebugLevel, "Stopping animation %d...", getID()); }
bool MeshBufferReader::trackFrame(int nFrame, unsigned char* pColorImageRGB, TrackerOutputInfo** pOutputInfo) { memcpy(pCurrentColorImageRGB, pColorImageRGB, 3*m_nWidth*m_nHeight); cv::Mat tempColorImageRGB(m_nHeight, m_nWidth, CV_8UC3, pCurrentColorImageRGB); tempColorImageRGB.convertTo(colorImage, cv::DataType<Vec3d>::type, 1./255); cv::split(colorImage, colorImageSplit); if(!setCurrentFrame(nFrame)) return false; int bufferPos = (currentFrameNo - startFrameNo) / nFrameStep; *pOutputInfo = &outputInfoPyramidBuffer[ bufferPos ][ nRenderingLevel ]; return true; }
void SS5Player::play(const AnimeRef* animeRef, int startFrameNo) { SS_ASSERT(animeRef); if (m_currentAnimeRef != animeRef){ m_currentAnimeRef = animeRef; allocParts(animeRef->m_numParts); setPartsParentage(); } setCurrentFrame(startFrameNo); setFrame(startFrameNo); //play実行時に最初のフレームのユーザーデータを確認する checkUserData(startFrameNo); checkEvent(startFrameNo); }
//! sets the frames between the animation is looped. //! the default is 0 - MaximalFrameCount of the mesh. bool CAnimatedMeshSceneNode::setFrameLoop(s32 begin, s32 end) { const s32 maxFrameCount = Mesh->getFrameCount() - 1; if ( end < begin ) { StartFrame = core::s32_clamp(end, 0, maxFrameCount); EndFrame = core::s32_clamp(begin, StartFrame, maxFrameCount); } else { StartFrame = core::s32_clamp(begin, 0, maxFrameCount); EndFrame = core::s32_clamp(end, StartFrame, maxFrameCount); } setCurrentFrame ( StartFrame ); return true; }
TEST_F(BitmapImageTest, correctDecodedDataSize) { // When requesting a frame of a multi-frame GIF causes another frame to be // decoded as well, both frames' sizes should be reported by the source and // thus included in the decoded size changed notification. loadImage("/LayoutTests/fast/images/resources/anim_none.gif", false); frameAtIndex(1); int frameSize = static_cast<int>(m_image->size().area() * sizeof(ImageFrame::PixelData)); EXPECT_EQ(frameSize * 2, m_imageObserver->m_lastDecodedSizeChangedDelta); // Trying to destroy all data except an undecoded frame should cause the // decoder to seek backwards and preserve the most recent previous frame // necessary to decode that undecoded frame, and destroy all other frames. setCurrentFrame(2); destroyDecodedData(false); EXPECT_EQ(-frameSize, m_imageObserver->m_lastDecodedSizeChangedDelta); }
void UndoTransaction::removeFrame(int frame) { ASSERT(frame >= 0); // Remove cels from this frame (and displace one position backward // all next frames) removeFrameOfLayer(m_sprite->getFolder(), frame); // New value for totalFrames propety int newTotalFrames = m_sprite->getTotalFrames()-1; // Move backward if we will be outside the range of frames if (m_sprite->getCurrentFrame() >= newTotalFrames) setCurrentFrame(newTotalFrames-1); // Decrement frames counter in the sprite setNumberOfFrames(newTotalFrames); }
void Sprite::animate(Uint16 start_frame, Uint16 end_frame) { Uint16 current_frame = getCurrentFrame(); if (current_frame < start_frame || current_frame > end_frame) { current_frame = start_frame; } else { ++current_frame; if (current_frame > end_frame) { current_frame = start_frame; } } setCurrentFrame(current_frame); }
//============================================================================= // Initialize the Bar // Pre: *graphics = pointer to Graphics object // *textureM = pointer to TextureManager object // left, top = screen location // scale = scaling (zoom) amount // color = color of bar // Post: returns true on success, false on error //============================================================================= bool Bar::initialize(Graphics *graphics, TextureManager *textureM, int left, int top, float scale, COLOR_ARGB color) { try { Image::initialize(graphics, dashboardNS::IMAGE_SIZE, dashboardNS::IMAGE_SIZE, dashboardNS::TEXTURE_COLS, textureM); setCurrentFrame(dashboardNS::BAR_FRAME); spriteData.x = (float)left; spriteData.y = (float)top; spriteData.scale = scale; colorFilter = color; } catch(...) { return false; } //return okay return true; }
Animation::Animation(string imageSource,string frames,float OffsetX, float OffsetY, float fps, bool doesLoop,int finalFrame) { setCurrentFrame(0); setModelSource(imageSource); setLoop(doesLoop); setOffset(OffsetX,0,OffsetY); setFinalFrame(finalFrame); setRate(fps); //setRotation(0,0,0); do { string FrameSelection=nextSet(&frames,','); if (FrameSelection!="") { int newFrame=atoi(FrameSelection.c_str()); frames_.push_back(newFrame); }; }while (frames.find(',')!=string::npos); };
// Metodo responsavel por fazer as atualizacoes necessarias para a correta // animacao do sprite. void Sprite::update(double deltaTime, bool updatePos) { if(updatePos) { // Move sprite according to its speed and the amount of time that has passed sf::Vector2f offset(xspeed/1000 * deltaTime, yspeed/1000 * deltaTime); move(offset); } if(animState == AnimState::PLAYING) { int lastf = curframe; curFrameD += (double)framedelay/1000*deltaTime; curframe = (int) curFrameD; if(curframe > lastFrame && looping || firstFrame == lastFrame) { curFrameD = firstFrame; curframe = firstFrame; } if(curframe != lastf) setCurrentFrame(curframe); } }
void IMFT<Ptr>::setFrame(VecPtr ptrs) { cnt++; if(m_isDebug) std::cout << "||CNT : " << cnt << " || # of objects : " << ptrs.size() << " || # of tracks : " << m_tracks.size() << " ||" <<std::endl; if(cnt > m_nWindow) movingWindow(); addToDGraph(ptrs); tracking(); if(cnt == m_nWindow) { backtracking(); makeTracks(); } else if(cnt > m_nWindow){ trackUpdate(); // setCurrentFrame(cnt); } setCurrentFrame(cnt); confirmDGraph(); }
bool MeshSequenceReader::trackFrame(int nFrame, unsigned char* pColorImageRGB, TrackerOutputInfo** pOutputInfo) { *pOutputInfo = &outputInfo; // if(!setCurrentFrame(nFrame)) return false; // set up the color used later memcpy(pCurrentColorImageRGB, pColorImageRGB, 3*m_nWidth*m_nHeight); cv::Mat tempColorImageRGB(m_nHeight, m_nWidth, CV_8UC3, pCurrentColorImageRGB); tempColorImageRGB.convertTo(colorImage, cv::DataType<Vec3d>::type, 1./255); cv::split(colorImage, colorImageSplit); if(!trackerInitialized) trackerInitSetup(outputInfo); else trackerUpdate(outputInfo); return true; }
bool Sprite::load(char filename[]) { tex = tm->findTexture(filename); if(tex == NULL) return false; spriteW = tex->getSize().x; spriteH = tex->getSize().y; // Add a single frame as the whole image sf::IntRect rect; rect.left = 0; rect.width = spriteW; rect.top = 0; rect.height = spriteH; cout << "image: " << rect.left << "," << rect.top << " - " << rect.width << "x" << rect.height << endl; frames.push_back(rect); totalFrames = frames.size(); setCurrentFrame(0); return true; }
void GameSprite::setAnimation(int anim){ //look up anim in spritemanager if(spriteDataIndex > spriteMan->spriteData.size()){ cout << "F**K" << endl; } currentImageData = &(spriteMan->spriteData[spriteDataIndex]); //cout << "setting animation for " << currentImageData->tag << endl; vector<Animation>::iterator it; bool ok; ok = false; for( it = currentImageData->animations.begin(); it != currentImageData->animations.end(); it++){ if(it->index == anim){ //cout << "Set animation id: " << anim << endl; currentAnimation.index = it->index; currentAnimation.numFrames = it->numFrames; currentAnimation.spriteRow = it->spriteRow; currentAnimation.animSpeed = it->animSpeed; currentAnimation.collisionMask = it->collisionMask; //cout << "got animation index: " << currentAnimation.numFrames << endl; currentFrame = 0; lastFrameTime = ofGetElapsedTimeMillis() - it->animSpeed - 10; ok = true; setCurrentFrame(currentFrame); if(currentAnimation.animSpeed > 0){ think(); } } } if(!ok){ cout << "setting animation that doesnt exist!! - " << anim << endl; } }
void DocInfo::scrollFrameBy(int delta) { int f = currentFrame(); int r = currentRow(); r += delta; doc()->lock(); if (r < 0) { if (f == 0) { // wrap to the end f = doc()->GetFrameCount()-1; } else { f--; } r = doc()->getFramePlayLength(f) + r; } else if ((unsigned int)r >= doc()->getFramePlayLength(f)) { r = r - doc()->getFramePlayLength(f); f++; if ((unsigned int)f >= doc()->GetFrameCount()) { // wrap to the beginning f = 0; } } doc()->unlock(); setCurrentFrame(f); setCurrentRow(r); }
void Player::setCurrentTime(int currentTime) { if (currentTime >= _recording->getLength()) { stopPlaying(); return; } // Find correct frame int lowestBound = 0; int highestBound = _recording->getFrameNumber() - 1; while (lowestBound + 1 != highestBound) { assert(lowestBound < highestBound); int bestGuess = lowestBound + (highestBound - lowestBound) * (float)(currentTime - _recording->getFrameTimestamp(lowestBound)) / (float)(_recording->getFrameTimestamp(highestBound) - _recording->getFrameTimestamp(lowestBound)); if (_recording->getFrameTimestamp(bestGuess) <= currentTime) { if (currentTime < _recording->getFrameTimestamp(bestGuess + 1)) { lowestBound = bestGuess; highestBound = bestGuess + 1; } else { lowestBound = bestGuess + 1; } } else { if (_recording->getFrameTimestamp(bestGuess - 1) <= currentTime) { lowestBound = bestGuess - 1; highestBound = bestGuess; } else { highestBound = bestGuess - 1; } } } setCurrentFrame(lowestBound); }
TupGraphicsScene::TupGraphicsScene() : QGraphicsScene(), k(new Private) { #ifdef K_DEBUG T_FUNCINFO; #endif setItemIndexMethod(QGraphicsScene::NoIndex); k->framePosition.layer = -1; k->framePosition.frame = -1; k->spaceMode = TupProject::FRAMES_EDITION; setCurrentFrame(0, 0); k->onionSkin.next = 0; k->onionSkin.previous = 0; k->tool = 0; k->isDrawing = false; setBackgroundBrush(Qt::gray); k->inputInformation = new TupInputDeviceInformation(this); k->brushManager = new TupBrushManager(this); }
PropertyTimelineWidget::PropertyTimelineWidget(std::string name, PropertyTimeline* propertyTimeline, QWidget* parent) : QWidget(parent) , propertyTimeline_(propertyTimeline) , inInterpolationMenu_(0) , outInterpolationMenu_(0) { guiName_ = name; id_ = name; mainLayout_ = new QHBoxLayout(this); mainLayout_->setMargin(0); mainLayout_->setSpacing(0); currentFrameGraphicsItem_ = new CurrentFrameGraphicsItem(false, false); smoothItem_ = new QGraphicsEllipseItem(0, 0, 8, 8); smoothItem_->setBrush(QBrush(QColor(50,255,50))); smoothItem_->moveBy(10, -7); smoothItem_->setCursor(Qt::ArrowCursor); smoothTextItem_ = new QGraphicsSimpleTextItem("smoothness"); smoothTextItem_->moveBy(22, -10); smoothGroup_ = new QGraphicsItemGroup(); smoothGroup_->addToGroup(smoothItem_); smoothGroup_->addToGroup(smoothTextItem_); smoothGroup_->hide(); smoothGroup_->setZValue(5); propertyTimelineScene_ = new QGraphicsScene(this); propertyTimelineView_ = new PropertyTimelineView(propertyTimelineScene_); propertyTimelineView_->setStyleSheet("background:transparent"); propertyTimelineView_->setFixedHeight(40); connect(propertyTimelineView_, SIGNAL(mousePressedAt(QPointF, const QGraphicsItem*)), this, SLOT(interpolationSelectorPressed(QPointF, const QGraphicsItem*))); inInterpolationSelector_ = new QGraphicsPixmapItem(QPixmap(":/qt/icons/1leftarrow.png")); outInterpolationSelector_ = new QGraphicsPixmapItem(QPixmap(":/qt/icons/1rightarrow.png")); inInterpolationSelector_->setCursor(Qt::ArrowCursor); outInterpolationSelector_->setCursor(Qt::ArrowCursor); inInterpolationSelector_->setMatrix(QMatrix(0.5, 0, 0, 0.5, 1, 1), true); outInterpolationSelector_->setMatrix(QMatrix(0.5, 0, 0, 0.5, 1, 1), true); propertyTimelineScene_->addItem(smoothGroup_); propertyTimelineScene_->addItem(inInterpolationSelector_); propertyTimelineScene_->addItem(outInterpolationSelector_); currentFrameCounter_ = propertyTimelineScene_->addText("0"); inInterpolationSelector_->setPos(20, 20); outInterpolationSelector_->setPos(40, 20); inInterpolationSelector_->setZValue(2); outInterpolationSelector_->setZValue(2); activateTimelineButton_ = new QPushButton(QIcon(":/qt/icons/apply.png"), "", this); showFrameHUD(false); activateTimelineButton_->setToolTip(tr("Activate or deactivate timeline")); activateTimelineButton_->setStyleSheet("QToolButton { border: none; padding: 1px; }"); activateTimelineButton_->setFlat(true); activateTimelineButton_->setFocusPolicy(Qt::NoFocus); activateTimelineButton_->setCheckable(true); activateTimelineButton_->setMaximumWidth(16); activateTimelineButton_->setMaximumHeight(16); activateTimelineButton_->setChecked(propertyTimeline->getActiveOnRendering()); // note: this is duplicated in activateTimeline() below if (!propertyTimeline->getActiveOnRendering()) activateTimelineButton_->setIcon(QIcon(":/qt/icons/button_cancel.png")); else activateTimelineButton_->setIcon(QIcon(":/qt/icons/apply.png")); connect(activateTimelineButton_, SIGNAL(toggled(bool)), this, SLOT(activateTimeline(bool))); setFps(30.0f); mainLayout_->addWidget(propertyTimelineView_); mainLayout_->addWidget(activateTimelineButton_); QLabel* nameLabel = new QLabel(this); nameLabel->move(8, 18); nameLabel->lower(); nameLabel->setText(QString::fromStdString(name)); nameLabel->setMinimumWidth(300); nameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); nameLabel->setEnabled(false); setCurrentFrame(0); propertyTimelineScene_->addItem(currentFrameGraphicsItem_); inInterpolationSelector_->show(); outInterpolationSelector_->show(); showFrameHUD(false); currentFrameGraphicsItem_->setPos(0, 1); currentFrameGraphicsItem_->setZValue(0.5); fps_ = 30.0f; setDuration(AnimationEditor::getDuration()); }
void Player::startPlaying() { if (!_recording || _recording->getFrameNumber() <= 1) { return; } if (!isPaused()) { _currentContext.globalTimestamp = usecTimestampNow(); _currentContext.domain = DependencyManager::get<NodeList>()->getDomainHandler().getHostname(); _currentContext.position = _avatar->getPosition(); _currentContext.orientation = _avatar->getOrientation(); _currentContext.scale = _avatar->getTargetScale(); _currentContext.headModel = _avatar->getFaceModelURL().toString(); _currentContext.skeletonModel = _avatar->getSkeletonModelURL().toString(); _currentContext.displayName = _avatar->getDisplayName(); _currentContext.attachments = _avatar->getAttachmentData(); _currentContext.orientationInv = glm::inverse(_currentContext.orientation); RecordingContext& context = _recording->getContext(); if (_useAttachments) { _avatar->setAttachmentData(context.attachments); } if (_useDisplayName) { _avatar->setDisplayName(context.displayName); } if (_useHeadURL) { _avatar->setFaceModelURL(context.headModel); } if (_useSkeletonURL) { _avatar->setSkeletonModelURL(context.skeletonModel); } bool wantDebug = false; if (wantDebug) { qCDebug(avatars) << "Player::startPlaying(): Recording Context"; qCDebug(avatars) << "Domain:" << _currentContext.domain; qCDebug(avatars) << "Position:" << _currentContext.position; qCDebug(avatars) << "Orientation:" << _currentContext.orientation; qCDebug(avatars) << "Scale:" << _currentContext.scale; qCDebug(avatars) << "Head URL:" << _currentContext.headModel; qCDebug(avatars) << "Skeleton URL:" << _currentContext.skeletonModel; qCDebug(avatars) << "Display Name:" << _currentContext.displayName; qCDebug(avatars) << "Num Attachments:" << _currentContext.attachments.size(); for (int i = 0; i < _currentContext.attachments.size(); ++i) { qCDebug(avatars) << "Model URL:" << _currentContext.attachments[i].modelURL; qCDebug(avatars) << "Joint Name:" << _currentContext.attachments[i].jointName; qCDebug(avatars) << "Translation:" << _currentContext.attachments[i].translation; qCDebug(avatars) << "Rotation:" << _currentContext.attachments[i].rotation; qCDebug(avatars) << "Scale:" << _currentContext.attachments[i].scale; } } // Fake faceshift connection _avatar->setForceFaceTrackerConnected(true); qCDebug(avatars) << "Recorder::startPlaying()"; setupAudioThread(); _currentFrame = 0; _timerOffset = 0; _timer.start(); } else { qCDebug(avatars) << "Recorder::startPlaying(): Unpause"; setupAudioThread(); _timer.start(); setCurrentFrame(_pausedFrame); _pausedFrame = INVALID_FRAME; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void FrameAnimationControl::skipToStart() { m_timer->stop(); setCurrentFrame(0); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void FrameAnimationControl::skipToEnd() { m_timer->stop(); setCurrentFrame(m_numFrames-1); }
double STexture::setVideoTime(double sec) { return setCurrentFrame(sec*fps+firstFrame) / fps; }
void PlayableCharacter::standLeft() { setCurrentFrame(4); }