Пример #1
0
        public Transition(Effect cEffectSource, Effect cEffectTarget)
            : this()
        {
			try
            {
                if (null == cEffectSource) // TODO проверять видео или только аудио.....
                    _cEffectSource = new Composite(1, 1);
                else
                    _cEffectSource = cEffectSource;
                if (null == cEffectTarget)
                    _cEffectTarget = new Composite(1, 1);
                else
                    _cEffectTarget = cEffectTarget;
                #region z-layer
                if (_cEffectSource.nLayer > _cEffectTarget.nLayer)
                    ((IEffect)this).nLayer = _cEffectTarget.nLayer;
                else
					((IEffect)this).nLayer = _cEffectSource.nLayer;
				#endregion
			}
			catch
			{
				Fail();
				throw;
			}
		}
Пример #2
0
			public Line(EffectVideo cEffect, Composite cParent)
            {
				aLine = new List<EffectVideo>();
                aLine.Add(cEffect);
                nWidth = cEffect.stArea.nWidth;
                nHeight = cEffect.stArea.nHeight;
                _cParent = cParent;
				Area stArea = _cParent.stArea;
                stArea.nHeight += nHeight;
				_cParent.stArea = stArea;
				stArea = cEffect.stArea;
				stArea.nTop = (short)(_cParent._nHeightTotal + cEffect.stArea.nTop);
				cEffect.stArea = stArea;
            }
Пример #3
0
			private void MessagesAddToRoll()
			{
				try
				{
					SMS cSMS = null;
					Queue<SMS> aqMessages = null;
					if (0 < _aqMessagesVIP.Count)
						aqMessages = _aqMessagesVIP;
					else
						aqMessages = _aqMessages;

					Queue<Composite> aqLines;
					Composite cLine;
					ushort nHeight, nTargetHeight, nLineHeight, nLineNextHeight = 0, nLinePreviousHeight, nPauseDuration = 0, nPreviousPauseDuration = 0;
					float nSpeed = _cPreferences.nSpeed / 25;
					int nLinesQty;
					int nIndex;
					uint nFramesIn = 0, nFrameTr = 0, nFrameOut = 0;
					int nDelay;
					float nMiddleRounded;
					float nMiddlePreviousRounded;
					int nCorrectionPosition = _cPreferences.nCorrectPosition;
					int nCorrectionDelay = _cPreferences.nCorrectDelay;
					ushort nPauseDurMax = (ushort)(25 * _cPreferences.nSecondsPerLine * 2 - 1);
					long nDeltaFrames;
					Animation cMask = _cMaskSingle;
					Roll.Keyframe[] aKeyframes = null;
					long nKeyFrame;

					lock (aqMessages)
					{
						while (0 < aqMessages.Count)
						{
							cSMS = aqMessages.Dequeue();
							if (SMS.Type.Photo == cSMS.eType && null != OnPhotoSetup)
								OnPhotoSetup("photos/" + cSMS.Phone + ".jpg");

							aqLines = new Queue<Composite>(cSMS.RollItemsGet((ushort)_cPreferences.stSize.Width));
							if (0 < (nLinesQty = aqLines.Count))
							{
								nPreviousPauseDuration = nPauseDuration;
								nDelay = _cRoll.nEffectsQty == 0 ? 0 : 1;
								nIndex = 1;
								nTargetHeight = _cRoll.stArea.nHeight;
								cMask = (2 < nLinesQty ? _cMaskMulti : _cMaskSingle);
								cLine = aqLines.Dequeue();
								cLine.iMask = cMask;
								cLine.nMaxOpacity = cSMS.cPreferences.nOpacity;
								cLine.nInDissolve = cSMS.cPreferences.nInDissolve;
								aKeyframes = new Roll.Keyframe[4];

								nHeight = nLineHeight = cLine.stArea.nHeight;

								nPauseDuration = (ushort)(25 * _cPreferences.nSecondsPerLine * (2 == nLinesQty ? 2 : 1));
								if (1 < nLinesQty)
									nHeight += (nLineNextHeight = aqLines.Peek().stArea.nHeight);

								// первая строка
								nMiddleRounded = (float)Math.Round((nTargetHeight + nHeight) / 2F);
								nFramesIn = (uint)Math.Round(nMiddleRounded / nSpeed);
								aKeyframes[0] = new Roll.Keyframe()
								{
									eType = Roll.Keyframe.Type.linear,
									nFrame = 0,
									nPosition = nTargetHeight
								};
								aKeyframes[1] = new Roll.Keyframe()
								{
									eType = Roll.Keyframe.Type.linear,
									nFrame = nFramesIn,
									nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
								};
								aKeyframes[2] = new Roll.Keyframe()
								{
									eType = Roll.Keyframe.Type.linear,
									nFrame = nFramesIn + nPauseDuration,
									nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
								};
								aKeyframes[3] = new Roll.Keyframe()
								{
									eType = Roll.Keyframe.Type.linear,
									nFrame = 2 * nFramesIn + nPauseDuration,
									nPosition = nTargetHeight - 2 * nMiddleRounded - 1
								};

								_cRoll.EffectAdd(cLine, aKeyframes, (uint)(nDelay * (nFramesIn + (nPreviousPauseDuration == 0 ? nPauseDurMax : nPreviousPauseDuration) + nCorrectionDelay)));

								while (0 < aqLines.Count)
								{
									nIndex++;
									cLine = aqLines.Dequeue();
									cLine.iMask = cMask;
									cLine.nMaxOpacity = cSMS.cPreferences.nOpacity;
									if (2 < nLinesQty && 0 < aqLines.Count)
									{
										nLinePreviousHeight = nLineHeight;
										nLineHeight = nLineNextHeight;
										nLineNextHeight = aqLines.Peek().stArea.nHeight;

										nMiddlePreviousRounded = nMiddleRounded;
										nMiddleRounded = (float)Math.Round((nTargetHeight + nLineHeight + nLineNextHeight) / 2f);
										nFramesIn = (uint)Math.Round((nMiddlePreviousRounded - nLinePreviousHeight) / nSpeed);
										nFrameTr = (uint)Math.Round((nMiddleRounded - (nMiddlePreviousRounded - nLinePreviousHeight)) / nSpeed);
										nFrameOut = (uint)Math.Round((nMiddleRounded + nCorrectionPosition) / nSpeed);

										if (2 == nIndex)
										{ // вторая строка, когда их больше двух
											nDeltaFrames = GapAppearingFrameGet(aKeyframes, nLinePreviousHeight) - 1;
											Roll.Keyframe[] aCurve = Roll.Keyframe.CopyCurve(aKeyframes);
											uint nFrameInFirst = (uint)(aCurve[3].nFrame - nPauseDuration) / 2;
											Roll.Keyframe.ChangeFramesInCurve(aCurve, -nDeltaFrames);
											Roll.Keyframe.ChangePointsInCurve(aCurve, nLineHeight);
											aCurve[3].nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition;
											aCurve[3].nFrame = aCurve[2].nFrame + nFrameTr;
											Array.Resize<Roll.Keyframe>(ref aCurve, 6);
											aCurve[4] = new Roll.Keyframe()
											{
												eType = Roll.Keyframe.Type.linear,
												nFrame = nKeyFrame = aCurve[3].nFrame + nPauseDuration,
												nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
											};
											aCurve[5] = new Roll.Keyframe()
											{
												eType = Roll.Keyframe.Type.linear,
												nFrame = nKeyFrame + nFrameOut,
												nPosition = nTargetHeight - 2 * nMiddleRounded
											};
											_cRoll.EffectAdd(cLine, aCurve);
											aKeyframes = aCurve;
										}
										else
										{ // начиная с третьей строки, но кроме последней
											nDeltaFrames = GapAppearingFrameGet(aKeyframes, nLinePreviousHeight) - 1;
											aKeyframes = new Roll.Keyframe[] {
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = 0,
													nPosition = nTargetHeight
												},
												new Roll.Keyframe() {
													eType = Roll.Keyframe.Type.linear,
													nFrame = nKeyFrame = nFramesIn,
													nPosition = nTargetHeight - nMiddlePreviousRounded + nLinePreviousHeight + nCorrectionPosition
												},
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = (nKeyFrame += nPauseDuration),
													nPosition = nTargetHeight - nMiddlePreviousRounded + nLinePreviousHeight + nCorrectionPosition
												},
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = (nKeyFrame += nFrameTr),
													nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
												},
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = (nKeyFrame += nPauseDuration),
													nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
												},
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = nKeyFrame + nFrameOut,
													nPosition = nTargetHeight - 2 * nMiddleRounded
												}
											};
											_cRoll.EffectAdd(cLine, aKeyframes, (uint)(nFramesIn - nDeltaFrames + nPauseDuration - (nFramesIn - nFrameTr)));
										}
									}

									if (0 == aqLines.Count)
									{
										if (2 == nIndex)
										{ // вторая и она же последняя
											long nDelta = GapAppearingFrameGet(aKeyframes, nLineHeight) - 1;
											Roll.Keyframe[] aCurve = Roll.Keyframe.CopyCurve(aKeyframes);
											Roll.Keyframe.ChangeFramesInCurve(aCurve, -nDelta);
											Roll.Keyframe.ChangePointsInCurve(aCurve, nLineHeight);
											_cRoll.EffectAdd(cLine, aCurve);
										}
										else
										{ // последняя, когда их больше двух
											Roll.Keyframe cKF4 = aKeyframes[4];
											Roll.Keyframe cKF5 = aKeyframes[5];

											nDeltaFrames = GapAppearingFrameGet(aKeyframes, nLineHeight) - 1;
											aKeyframes = new Roll.Keyframe[] {
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = 0,
													nPosition = nTargetHeight
												},
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = nFramesIn,
													nPosition = nTargetHeight - nMiddleRounded + nLineHeight + nCorrectionPosition
												},
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = nFramesIn + nPauseDuration,
													nPosition = nTargetHeight - nMiddleRounded + nLineHeight + nCorrectionPosition
												},
												new Roll.Keyframe()
												{
													eType = Roll.Keyframe.Type.linear,
													nFrame = nFramesIn + nPauseDuration + (cKF5.nFrame - cKF4.nFrame),
													nPosition = nTargetHeight - nMiddleRounded + nLineHeight + nCorrectionPosition + (cKF5.nPosition - cKF4.nPosition)
												}
											};
											_cRoll.EffectAdd(cLine, aKeyframes, (uint)(nFramesIn - nDeltaFrames + nPauseDuration - (nFramesIn - nFrameTr)));
										}
									}
								}
								Composite cSpace = new Composite(1, 1)
								{
									bCUDA = false,
									oTag = cSMS
								};
								_cRoll.EffectAdd(cSpace, true);
							}
							cSMS = null;
						}
					}
				}
				catch (Exception ex)
				{
					(new Logger()).WriteError(ex);
				}
			}
Пример #4
0
        private void MakeComposites(XmlNode cXmlNode, string sDefaultID, Composite cRetVal)
        {
            XmlNode[] aNodes = cXmlNode.NodesGet("item", false);
            string sID = cXmlNode.AttributeValueGet("id", false);
            if (null == sID)
                sID = sDefaultID;
            if (!aNodes.IsNullOrEmpty())
            {
                foreach (XmlNode cXN in aNodes)
                    MakeComposites(cXN, sID, cRetVal);
                return;
            }
            Preferences.Item.Text cPreferencesItem = (Preferences.Item.Text)_cPreferences[sID];
            string sText = cXmlNode.InnerText;
            sText = sText.RemoveNewLines();
            if (0 == _nWidthOfSpace)
                _nWidthOfSpace = (ushort)(BTL.Play.Text.Measure("SSS SSS", cPreferencesItem.cFont, 0).nWidth - BTL.Play.Text.Measure("SSSSSS", cPreferencesItem.cFont, 0).nWidth);
            List<EffectVideo> aEffects = new List<EffectVideo>();
            ushort nIdent = 0;

            Text cText = new BTL.Play.Text(sText, cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder };
            ushort nMaxWidth = _cPreferences.stArea.nWidth;
            if (nMaxWidth < cText.stArea.nWidth)
            {
                List<string> aSplited = new List<string>();
                int nk = 0;
                bool bLastLetter = false, bLastDigit = false; //, bLastLetter = false;
                for (int ni = 0; sText.Length > ni; ni++)
                {
                    if (0 != ni && ((!bLastDigit && !bLastLetter && Char.IsLetterOrDigit(sText[ni])) || (bLastLetter && !(Char.IsLetter(sText[ni]))) || (bLastDigit && !(Char.IsDigit(sText[ni])))))
                    {
                        aSplited.Add(sText.Substring(nk, ni - nk));
                        nk = ni;
                    }
                    bLastLetter = Char.IsLetter(sText[ni]);
                    bLastDigit = Char.IsDigit(sText[ni]);
                }
                foreach (string sStr in aSplited)
                {
                    cText = new BTL.Play.Text(sStr, cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder };
                    Text cTextPrev = null; ;
                    int ni = 0;
                    nk = 1;
                    if (nMaxWidth < cText.stArea.nWidth)
                    {
                        while (ni + nk < sStr.Length)
                        {
                            cText = new BTL.Play.Text(sStr.Substring(ni, nk), cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder };
                            while (nMaxWidth > cText.stArea.nWidth && (ni + nk < sStr.Length))
                            {
                                nk++;
                                cTextPrev = cText;
                                cText = new BTL.Play.Text(sStr.Substring(ni, nk), cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder };
                            }
                            ni += nk - 1;
                            nk = 1;
                            if (ni + nk == sStr.Length)
                                cTextPrev = cText;
                            aEffects.Add(cTextPrev);
                        }
                    }
                    else
                        aEffects.Add(cText);
                }
            }
            else
				aEffects.Add(cText);

			nIdent = 0;
			for(int nIndx = 0; aEffects.Count > nIndx; nIndx++)
			{
				if (cRetVal.stArea.nWidth + aEffects[nIndx].stArea.nWidth + nIdent > nMaxWidth)
					break;
				aEffects[nIndx].stArea = new Area(aEffects[nIndx].stArea.nLeft, (short)(aEffects[nIndx].stArea.nTop + cPreferencesItem.nTopOffset), aEffects[nIndx].stArea.nWidth, aEffects[nIndx].stArea.nHeight); 
				cRetVal.EffectAdd(aEffects[nIndx], nIdent);
				nIdent = _nWidthOfSpace;
			}
        }
Пример #5
0
        private Composite ItemParse(Item cItem)
        {
			Composite cRetVal = new Composite(_cPreferences.stArea.nWidth, Composite.Type.Vertical);
			cRetVal.bCUDA = _cPreferences[null].bCuda;
			MakeComposites(cItem.cXmlNode, null, cRetVal);
			return cRetVal;
        }
Пример #6
0
 internal void EffectTargetSet(IEffect cEffectTarget)
 {
     if (null == cEffectTarget)
     {
         _cEffectTarget = new Composite(1, 1);
         bTargetNonStop = false;
     }
     else
         _cEffectTarget = cEffectTarget;
 }
Пример #7
0
        private List<Composite> MakeComposites(List<Item> aItems, ushort nMaxWidth)
        {
            List<Composite> aRetVal = new List<Composite>();
            ushort nIdent = 0;
            List<EffectVideo> aEffectsInSMS = new List<EffectVideo>();
            List<EffectVideo> aEff;
            int nIndx = 0;

            foreach (Item cItem in aItems)
                if (null != (aEff = cItem.GetEffect(this, nMaxWidth)))
                    aEffectsInSMS.AddRange(aEff);
            Composite cTemp;
            while (nIndx < aEffectsInSMS.Count)
            {
                cTemp = new Composite(nMaxWidth, Composite.Type.Vertical);
				
                nIdent = 0;
                while (true)
                {
                    if (cTemp.stArea.nWidth + aEffectsInSMS[nIndx].stArea.nWidth + nIdent > nMaxWidth)
                        break;

                    cTemp.EffectAdd(aEffectsInSMS[nIndx], nIdent);
                    nIdent = _nWidthOfSpace;
                    nIndx++;
                    if (nIndx >= aEffectsInSMS.Count)
                        break;
                }
                cTemp.bCUDA = false;

                aRetVal.Add(cTemp);
            }
            return aRetVal;
        }