public void Close() { lock (_oCloseLock) { if (_bClosed) { return; } _bClosed = true; } (new Logger()).WriteDebug3("in " + GetHashCode()); Logger.Timings cTimings = new Logger.Timings("video:file:"); Baetylus.PixelsMapDispose(_cPMDuo, true); _aAudioMap = null; cTimings.Restart("pm disposing"); if (null != _cFile) { _cFile.Dispose(); } cTimings.Stop("close > 20", "file disposing", 20); (new Logger()).WriteDebug4("out"); }
override public void Dispose() { if (_oLock == null) { return; } lock (_oLock) { if (_bDisposed) { return; } _bDisposed = true; } base.Dispose(); if (null != _cPMDuo) { (new Logger()).WriteDebug3("disposing pixelmap in animation: [hc=" + this.nID + "][file=" + (null == _cFile ? "null" : _cFile.sName) + "]"); Baetylus.PixelsMapDispose(_cPMDuo, true); } _cPMDuo = null; nFrameCurrentPhysical = 0; nLoopCurrent = 0; _cFile.Dispose(); }
private void DrawText() { BitmapData cBitmapData = _cImage.LockBits(new Rectangle(0, 0, _cImage.Width, _cImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); lock (_cSyncRoot) { if (_aDrawCurrent != null) { Baetylus._cBinM.BytesBack(_aDrawCurrent, 51); } _aDrawCurrent = Baetylus._cBinM.BytesGet(cBitmapData.Stride * cBitmapData.Height, 52); System.Runtime.InteropServices.Marshal.Copy(cBitmapData.Scan0, _aDrawCurrent.aBytes, 0, cBitmapData.Stride * cBitmapData.Height); _aPMGotDrawCurrent.Clear(); if (null != _cPMDuo && stArea != _cPMDuo.cFirst.stArea) { Baetylus.PixelsMapDispose(_cPMDuo, true); _cPMDuo = null; } if (null == _cPMDuo) { _cPMDuo = new PixelsMap.Triple(stMergingMethod, stArea, PixelsMap.Format.ARGB32, true, Baetylus.PixelsMapDispose); _cPMDuo.SetAlphaConstant(_stColor.A); _cPMDuo.Allocate(); } _dtChanged = DateTime.Now; } _cImage.UnlockBits(cBitmapData); _cImage = null; }
override public void Stop() { Baetylus.PixelsMapDispose(_cPMDuo, true); _cPMDuo = null; base.Stop(); }
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); }
override public void Prepare() { lock (_aEffects) try { if (EffectStatus.Idle != ((IEffect)this).eStatus) { return; } if (stMergingMethod.eDeviceType == MergingDevice.DisCom) { PixelsMap.DisComInit(); } foreach (Effect cEffect in _aEffects) { if (EffectStatus.Idle == cEffect.eStatus) { ((IVideo)cEffect).stMergingMethod = this.stMergingMethod; cEffect.Prepare(); } } if (null != _cPMDuo && stArea != _cPMDuo.cFirst.stArea) { Baetylus.PixelsMapDispose(_cPMDuo, true); _cPMDuo = null; } if (null == _cPMDuo) { _cPMDuo = new PixelsMap.Triple(this.stMergingMethod, this.stArea, PixelsMap.Format.ARGB32, true, Baetylus.PixelsMapDispose); if (1 > _cPMDuo.cFirst.nLength) { (new Logger()).WriteNotice("1 > __cPixelsMap.nLength. composite.prepare"); } _cPMDuo.Allocate(); } _cPMDuo.RenewFirstTime(); nPixelsMapSyncIndex = byte.MaxValue; base.Prepare(); } catch (Exception ex) { (new Logger()).WriteError(ex); } }
override public void Prepare() { base.Prepare(); if (0 == nDuration) { nDuration = 1; } if (stMergingMethod.eDeviceType == MergingDevice.DisCom) { PixelsMap.DisComInit(); } if (EffectStatus.Idle == _cEffectSource.eStatus || EffectStatus.Stopped == _cEffectSource.eStatus) { _cEffectSource.Prepare(); } if (EffectStatus.Idle == _cEffectTarget.eStatus || EffectStatus.Stopped == _cEffectTarget.eStatus) { _cEffectTarget.Prepare(); } if (_cEffectSource is IVideo && _cEffectTarget is IVideo) { stArea = SumOfAreas(((IVideo)_cEffectSource).stArea, ((IVideo)_cEffectTarget).stArea); if (null != _cPMDuo && stArea != _cPMDuo.cFirst.stArea) { Baetylus.PixelsMapDispose(_cPMDuo, true); _cPMDuo = null; } if (null == _cPMDuo) { //_cPixelsMap = new PixelsMap(stMergingMethod, stArea, PixelsMap.Format.ARGB32); _cPMDuo = new PixelsMap.Triple(new MergingMethod(stMergingMethod.eDeviceType, 0), stArea, PixelsMap.Format.ARGB32, true, Baetylus.PixelsMapDispose); //MergingDevice.DisCom if (1 > _cPMDuo.cFirst.nLength) { (new Logger()).WriteNotice("1 > _cPixelsMap.nLength. transition.prepare"); } _cPMDuo.Allocate(); } _cPMDuo.RenewFirstTime(); nPixelsMapSyncIndex = byte.MaxValue; } }
public override void Dispose() { lock (_oLock) { if (_bDisposed) { return; } _bDisposed = true; } base.Dispose(); lock (_cSyncRoot) { Baetylus.PixelsMapDispose(_cPMDuo, true); //_cPMDuo.Dispose(true); _cPMDuo = null; } }
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); }