You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
C++
59 lines
1.9 KiB
C++
#include "nmPebiResultAnimationExportSettings.h"
|
|
|
|
nmPebiResultAnimationExportSettings::nmPebiResultAnimationExportSettings()
|
|
: m_nFramesPerSecond(15),
|
|
m_nStartFrameIndex(0),
|
|
m_nEndFrameIndex(0),
|
|
m_nSamplingInterval(1),
|
|
m_nOutputWidth(2),
|
|
m_nOutputHeight(2)
|
|
{
|
|
}
|
|
|
|
bool nmPebiResultAnimationExportSettings::isValid(
|
|
int nAvailableFrameCount) const
|
|
{
|
|
return nAvailableFrameCount > 0 &&
|
|
m_nFramesPerSecond >= 1 && m_nFramesPerSecond <= 5000 &&
|
|
m_nStartFrameIndex >= 0 &&
|
|
m_nEndFrameIndex >= m_nStartFrameIndex &&
|
|
m_nEndFrameIndex < nAvailableFrameCount &&
|
|
m_nSamplingInterval >= 1 &&
|
|
m_nSamplingInterval <=
|
|
qMax(1, m_nEndFrameIndex - m_nStartFrameIndex) &&
|
|
m_nOutputWidth >= 2 && m_nOutputWidth <= 8192 &&
|
|
m_nOutputHeight >= 2 && m_nOutputHeight <= 8192 &&
|
|
(m_nOutputWidth % 2) == 0 &&
|
|
(m_nOutputHeight % 2) == 0;
|
|
}
|
|
|
|
QVector<int> nmPebiResultAnimationExportSettings::buildFrameIndices() const
|
|
{
|
|
QVector<int> vecFrameIndices;
|
|
if(m_nStartFrameIndex < 0 ||
|
|
m_nEndFrameIndex < m_nStartFrameIndex ||
|
|
m_nSamplingInterval < 1) {
|
|
return vecFrameIndices;
|
|
}
|
|
|
|
// 先按间隔采样;不能整除时在循环后显式补入结束帧。
|
|
for(int nFrameIndex = m_nStartFrameIndex;
|
|
nFrameIndex <= m_nEndFrameIndex;
|
|
nFrameIndex += m_nSamplingInterval) {
|
|
vecFrameIndices.append(nFrameIndex);
|
|
if(m_nEndFrameIndex - nFrameIndex < m_nSamplingInterval) {
|
|
break;
|
|
}
|
|
}
|
|
if(vecFrameIndices.isEmpty() ||
|
|
vecFrameIndices.last() != m_nEndFrameIndex) {
|
|
vecFrameIndices.append(m_nEndFrameIndex);
|
|
}
|
|
return vecFrameIndices;
|
|
}
|
|
|
|
int nmPebiResultAnimationExportSettings::getOutputFrameCount() const
|
|
{
|
|
return buildFrameIndices().size();
|
|
}
|