예제 #1
0
        override public PixelsMap FrameNext()   // если население композита тексты и они не менялись, то можно ничего не менять вообще! (оптимизация чата и подобных)  // сделал
        {
            _cPixelsMap = _cPMDuo.Switch(nPixelsMapSyncIndex);
            if (null == _cPixelsMap)
            {
                return(null);
            }

            _bChanged = false;
            base.FrameNext();
            PixelsMap        cPM  = null;
            List <PixelsMap> aPMs = new List <PixelsMap>();
            Dictionary <Effect, PixelsMap> ahEffects_PMs = new Dictionary <Effect, PixelsMap>();
            IVideo iVideo = null;

            foreach (Effect cEffect in _aEffects)
            {
                if (null == cEffect || !(cEffect is IVideo) || (EffectStatus.Running != cEffect.eStatus))
                {
                    continue;
                }
                iVideo = (IVideo)cEffect;
                iVideo.nPixelsMapSyncIndex = nPixelsMapSyncIndex;
                cPM = iVideo.FrameNext();
                if (null == cPM)
                {
                    continue;
                }
                aPMs.Add(cPM);
                if (!_bChanged && (!(iVideo is Text) || ((Text)iVideo).dtChanged > _dtLastChange))
                {
                    _bChanged = true;
                }
            }

            if (_bChanged && 0 < aPMs.Count)   // когда == 0   - это пустышка и не надо для нее делать pixelsmap   //  || _bMergedChanges
            {
                //_bMergedChanges = _bChanged;
                _dtLastChange = DateTime.Now;
                _cPixelsMap.Merge(aPMs);
                Baetylus.PixelsMapDispose(aPMs.ToArray());
            }

            _cPixelsMap.nAlphaConstant = nCurrentOpacity;
            if (null != cMask)
            {
                _cPixelsMap.eAlpha = cMask.eMaskType;
            }

            _cPixelsMap.Move(stArea.nLeft, stArea.nTop);

            if (nFrameCurrent >= nDuration)
            {
                base.Stop();
            }
            return(_cPixelsMap);
        }
예제 #2
0
        override public PixelsMap FrameNextVideo()
        {
            if (!(_cEffectSource is IVideo) && !(_cEffectTarget is IVideo))
            {
                return(null);
            }
            if (nDuration == _nFramesCounterVideo)
            {
                return(null);
            }
            _nFramesCounterVideo++;
            List <PixelsMap>             aFrames = new List <PixelsMap>();
            PixelsMap                    cFrame;
            Dictionary <PixelsMap, byte> nAlphaConstantOld = new Dictionary <PixelsMap, byte>();
            float  nProgress             = (float)_nFramesCounterVideo / (float)nDuration;
            bool   bIfLayersHave255Alpha = true;
            IVideo iVideo;

            if (_cEffectSource is IVideo)
            {
                iVideo = (IVideo)_cEffectSource;
                iVideo.nPixelsMapSyncIndex = nPixelsMapSyncIndex;
                if (null != (cFrame = iVideo.FrameNext()))
                {
                    if (cFrame.nAlphaConstant < 255)
                    {
                        bIfLayersHave255Alpha = false;
                    }
                    nAlphaConstantOld.Add(cFrame, cFrame.nAlphaConstant);
                    //if(null != iVideo.iMask)
                    //               {
                    //                   aFrames.Add(iVideo.iMask.FrameNext());
                    //                   aFrames[aFrames.Count - 1].eAlpha = DisCom.Alpha.mask;
                    //               }
                    aFrames.Add(TransitionVideoFrame(cFrame, eTransitionTypeVideo, nProgress));
                }
            }
            if (_cEffectTarget is IVideo)
            {
                if (0.5 == nProgress)  // избегаем коллизии ровной середины
                {
                    nProgress = 0.501F;
                }
                iVideo = (IVideo)_cEffectTarget;
                iVideo.nPixelsMapSyncIndex = nPixelsMapSyncIndex;
                if (null != (cFrame = iVideo.FrameNext()))
                {
                    if (cFrame.nAlphaConstant < 255)
                    {
                        bIfLayersHave255Alpha = false;
                    }
                    nAlphaConstantOld.Add(cFrame, cFrame.nAlphaConstant);
                    //if (null != iVideo.iMask)
                    //{
                    //    aFrames.Add(iVideo.iMask.FrameNext());
                    //    aFrames[aFrames.Count - 1].eAlpha = DisCom.Alpha.mask;
                    //}
                    aFrames.Add(TransitionVideoFrame(cFrame, eTransitionTypeVideo, 1 - nProgress));
                }
            }
            if (2 == aFrames.Count && aFrames[0].stArea == aFrames[1].stArea && bIfLayersHave255Alpha)
            {
                aFrames[0].nAlphaConstant = byte.MaxValue;
            }

            //PixelsMap cRetVal = PixelsMap.Merge(stArea, aFrames);
            //EMERGENCY:l тут мы, между прочим, для каждого кадра делаем пикселсмэп, а это очень неэффективно...
            // И не надо отправлять в мердж, если эффект только один (уход в черное) - просто меняем ему конст альфу
            PixelsMap cRetVal = _cPMDuo.Switch(nPixelsMapSyncIndex);

            if (cRetVal == null)
            {
                return(null);
            }

            cRetVal.Merge(aFrames);

            if (null != cRetVal && null != cMask)
            {
                cRetVal.eAlpha = cMask.eMaskType;
            }
            foreach (PixelsMap cPM in aFrames)
            {
                if (nAlphaConstantOld.ContainsKey(cPM))
                {
                    cPM.nAlphaConstant = nAlphaConstantOld[cPM];
                }
                Baetylus.PixelsMapDispose(cPM);
            }
            if (EffectStatus.Running != _cEffectTarget.eStatus ||
                (nDuration == _nFramesCounterVideo &&
                 (_nFramesCounterVideo == _nFramesCounterAudio ||
                  (!(_cEffectSource is IAudio) && !(_cEffectTarget is IAudio))
                 )
                )
                )
            {
                Stop();
            }
            return(cRetVal);
        }