Exemple #1
0
 private static void CheckTagValidity(ISwfTag tag)
 {
     if (
         tag is ShowFrameTag ||
         tag is PlaceObjectTag ||
         tag is PlaceObject2Tag ||
         tag is RemoveObjectTag ||
         tag is RemoveObject2Tag ||
         tag is FrameLabelTag ||
         tag is DoActionTag ||
         //tag is StartSoundTag ||
         //tag is SoundStreamHeadTag ||
         //tag is SoundStreamHead2Tag ||
         //tag is SoundStreamBlockTag ||
         tag is EndTag)
             return;
     throw new SwfCorruptedException("Invalid tag '" + tag.ToString() + "' found inside DefineSprite!");
 }
Exemple #2
0
        internal void AddInfo(ISwfTag tag, ISystemServices services)
        {
            if (tag is DefineFontInfoTag)
            {
                var i = (tag as DefineFontInfoTag);
                SetDeviceFont(i.Name, i.Characters, services);
            }
            else if (tag is DefineFontTag)
                GlyphFont = (tag as DefineFontTag).Glyphs;
            else if (tag is DefineFont2Tag)
            {
                var font = tag as DefineFont2Tag;

                if (font.Glyphs != null && font.Glyphs.Length > 0)
                    GlyphFont = font.Glyphs;

                if (!string.IsNullOrEmpty(font.Name))
                    SetDeviceFont(font.Name, font.Characters, services);
            }
        }
Exemple #3
0
        private void ParseTag(ISwfTag tag)
        {
            switch (tag.TagType)
            {
                case TagType.DefineSprite:
                    ParseDefineSpriteTag((DefineSpriteTag)tag);
                    break;
                case TagType.DefineShape:
                    ParseDefineShapeTag((DefineShapeTag)tag);
                    break;
                case TagType.DefineShape2:
                    ParseDefineShape2Tag((DefineShape2Tag)tag);
                    break;
                case TagType.DefineShape3:
                    ParseDefineShape3Tag((DefineShape3Tag)tag);
                    break;
                case TagType.DefineShape4:
                    ParseDefineShape4Tag((DefineShape4Tag)tag);
                    break;
                case TagType.JPEGTables:
                    // not retained
                    break;
                case TagType.DefineBits:
                    ParseDefineBits((DefineBitsTag)tag);
                    break;
                case TagType.DefineBitsJPEG2:
                    ParseDefineBits((DefineBitsTag)tag);
                    break;
                case TagType.DefineBitsJPEG3:
                    ParseDefineBits((DefineBitsTag)tag);
                    break;
                case TagType.DefineBitsLossless:
                    ParseDefineBitsLossless((DefineBitsLosslessTag)tag);
                    break;
                case TagType.DefineBitsLossless2:
                    if (!addedFullBitmap)
                    {
                        addedFullBitmap = true;
                        DefineBitsLosslessTag t = (DefineBitsLosslessTag)tag;
                        fullBitmapId = t.CharacterId;
                        //DefineBitsLosslessTag t = new DefineBitsLosslessTag(true);
                        //t.CharacterId = ot.CharacterId;
                        //t.BitmapFormat = ot.BitmapFormat;
                        t.Width = (uint)fullBitmap.Bitmap.Width;
                        t.Height = (uint)fullBitmap.Bitmap.Height;
                        t.OrgBitmapData = null;
                        uint pxCount = t.Width * t.Height;
                        RGBA[] pxs = new RGBA[pxCount];

                        fullBitmap.LockBitmap();
                        for (int i = 0; i < pxCount; i++)
                        {
                            int x = (int)(i % t.Width);
                            int y = (int)(Math.Floor((double)(i / t.Width)));
                            PixelData pd = fullBitmap.GetPixel(x, y);
                            pxs[i] = new RGBA(pd.red, pd.green, pd.blue, pd.alpha);
                        }
                        t.BitmapData = pxs;
                        fullBitmap.UnlockBitmap();
                    }
                    break;
                case TagType.UnsupportedDefinition:
                    break;
            }
        }
Exemple #4
0
        protected override void UnhandledTag(ISwfTag tag, ISystemServices services)
        {
            if (tag is ISwfDefinitionTag)
            {
                var defTag = tag as ISwfDefinitionTag;

                ICharacter character = null;
                switch (defTag.Type)
                {
                    case CharacterType.BinaryData: character = new BinaryData(defTag.CharacterID, (tag as DefineBinaryDataTag).Data); break;
                    case CharacterType.Bitmap: character = new Bitmap(defTag, services); break;
                    case CharacterType.Button: character = new ButtonInfo(defTag, services, this); break;
                    case CharacterType.Shape: character = new Shape(defTag, services, this); break;
                    case CharacterType.Text: character = new Text(tag as DefineTextTag, services, this); break;
                    case CharacterType.Sprite:
                        {
                            var sprite = tag as DefineSpriteTag;
                            character = new Sprite(sprite.Tags, defTag.CharacterID, sprite.FrameCount, services);
                        }
                        break;
                    case CharacterType.Font:
                        {
                            var font = new Font(defTag.CharacterID);
                            font.AddInfo(tag, services);
                            character = font;
                        }
                        break;
                }

                if (character != null)
                    _characters.Add(defTag.CharacterID, character);
            }
            else if (tag is SetBackgroundColorTag)
            {
                BackgroundColor = (tag as SetBackgroundColorTag).Color;
            }
            else if (tag is DefineScenesAndFrameLabelsTag)
            {
                var def = tag as DefineScenesAndFrameLabelsTag;
                _frameLabels = new Dictionary<string, ushort>(def.FrameLabels);
                _scenes = new Dictionary<string, ushort>(def.Scenes);
            }
            else if (tag is DefineFontInfoTag)
            {
                var fi = tag as DefineFontInfoTag;
                (_characters[fi.FontID] as Font).AddInfo(tag, services);
            }
            else if (tag is DoInitActionTag)
            {
                var init = tag as DoInitActionTag;
                (_characters[init.SpriteID] as Sprite).InitAction = init.Actions;
                _initOrder.Add(init.SpriteID);
            }
            else if (tag is DefineButtonCxFormTag)
            {
                var cxf = tag as DefineButtonCxFormTag;
                (_characters[cxf.CharacterID] as ButtonInfo).SetCxForm(cxf.CxForm);
            }

            #region Not implemented tags

            /*
            else if (tag is DefineEditTextTag) { }
             */

            // else if (tag is SetTabIndexTag) { }
            // else if (tag is DefineScalingGridTag) { }
            else
                base.UnhandledTag(tag, services);

            #endregion

            #region Unsupported tags
            //TODO: Tags not yet implemented or unsupported
            //DefineFontNameTag
            //{14, "DefineSound"},
            //{17, "DefineButtonSound"},
            //{24, "Protect"},
            //{46, "DefineMorphShape"},
            //{56, "ExportAssets"},
            //{57, "ImportAssets"},
            //{58, "EnableDebugger"},
            //{60, "DefineVideoStream"},
            //{61, "VideoFrame"},
            //{64, "EnableDebugger2"},
            //{65, "ScriptLimits"},
            //{69, "FileAttributes"},
            //{71, "ImportAssets2"},
            //{73, "DefineFontAlignZones"},
            //{74, "CSMTextSettings"},
            //{76, "SymbolClass"},
            //{77, "Metadata"},
            //{84, "DefineMorphShape2"},
            //{89, "StartSound2"},
            //{91, "DefineFont4"}
            #endregion
        }
Exemple #5
0
		private void ParseTag(ISwfTag tag)
		{
			switch (tag.TagType)
			{
				case TagType.FileAttributes:
					ParseFileAttributesTag((FileAttributesTag)tag);
					break;
				case TagType.BackgroundColor:
					ParseBackgroundColor((BackgroundColorTag)tag);
					break;
				case TagType.End:
					// nothing to do
					break;
				case TagType.DefineSprite:
					ParseDefineSpriteTag((DefineSpriteTag)tag);
					break;
				case TagType.PlaceObject:
					ParsePlaceObjectTag((PlaceObjectTag)tag);
					break;
				case TagType.PlaceObject2:
					ParsePlaceObject2Tag((PlaceObject2Tag)tag);
					break;
				case TagType.PlaceObject3:
					ParsePlaceObject3Tag((PlaceObject3Tag)tag);
					break;
				case TagType.RemoveObject:
					ParseRemoveObjectTag((RemoveObjectTag)tag);
					break;
				case TagType.RemoveObject2:
					ParseRemoveObject2Tag((RemoveObject2Tag)tag);
					break;
				case TagType.ShowFrame:
					curFrame += 1;
					break;
				case TagType.FrameLabel:
					uint curTime = (uint)((curFrame * (1 / swf.Header.FrameRate)) * 1000);
					curTimeline.Labels.Add(new Label(curTime, ((FrameLabelTag)tag).TargetName));
                    break;
                case TagType.DefineShape:
                    ParseDefineShapeTag((DefineShapeTag)tag);
                    break;
                case TagType.DefineShape2:
                    ParseDefineShape2Tag((DefineShape2Tag)tag);
                    break;
				case TagType.DefineShape3:
					ParseDefineShape3Tag((DefineShape3Tag)tag);
					break;
				case TagType.DefineShape4:
					ParseDefineShape4Tag((DefineShape4Tag)tag);
					break;
				case TagType.JPEGTables:
					// not retained
					break;
				case TagType.DefineBits:
					ParseDefineBits((DefineBitsTag)tag);
					break;
				case TagType.DefineBitsJPEG2:
                   // v.NextId();
                    ParseDefineBits((DefineBitsTag)tag);
					//ParseDefineBitsJPEG2((DefineBitsJPEG2Tag)tag);
					break;
				case TagType.DefineBitsJPEG3:
                    //v.NextId();
                    ParseDefineBits((DefineBitsTag)tag);
					//ParseDefineBitsJPEG3((DefineBitsJPEG3Tag)tag);
					break;
				case TagType.DefineBitsLossless:
					ParseDefineBitsLossless((DefineBitsLosslessTag)tag);
					break;
				case TagType.DefineBitsLossless2:
					ParseDefineBitsLossless((DefineBitsLosslessTag)tag);
					break;
				case TagType.DefineSound:
					ParseDefineSound((DefineSoundTag)tag);
					break;
				case TagType.StartSound:
					ParseStartSound((StartSoundTag)tag);
					break;
				case TagType.SoundStreamHead:
					ParseSoundStreamHead((SoundStreamHeadTag)tag);
					break;
				case TagType.SoundStreamBlock:
					if (lastSoundDef != null)
					{
						lastSoundDef.StartTime = (uint)((curFrame * (1 / swf.Header.FrameRate)) * 1000);
						lastSoundDef = null;
					}
					break;
				case TagType.DefineFontInfo:
					break;
				case TagType.DefineFontInfo2:
					break;
				case TagType.DefineFont:  //temp
					v.NextId();
					break;
				case TagType.DefineFont2: //temp
					v.NextId();
					break;
				case TagType.DefineFont3: //temp
					v.NextId();
					break;
				case TagType.DefineFontAlignZones:
					break;
				case TagType.CSMTextSettings:
					break;
				case TagType.DefineText:
					ParseDefineText((DefineTextTag)tag);
					break;
				case TagType.DefineText2:
					ParseDefineText((DefineTextTag)tag);
					break;
				case TagType.DefineEditText:
					ParseEditText((DefineEditTextTag)tag);
					break;
				case TagType.ExportAssets:
				    ParseExportAssets((ExportAssetsTag)tag);
				    break;

				case TagType.UnsupportedDefinition:
					v.NextId();
					Log.AppendLine(
						((UnsupportedDefinitionTag)tag).Message + 
						" at frame " + this.curFrame + 
						" in clip " + this.curTimeline.Name);
					break;


				//case TagType.DefineButtonCxform:
				//	ParseDefineButtonCxform((DefineButtonCxformTag)tag);
				//	break;

				//case TagType.Protect:
				//	ParseProtect((ProtectTag)tag);
				//	break;

				//case TagType.PathsArePostScript:
				//	ParsePathsArePostScript((PathsArePostScriptTag)tag);
				//	break;

				//case TagType.SyncFrame:
				//	ParseSyncFrame((SyncFrameTag)tag);
				//	break;

				//case TagType.FreeAll:
				//	ParseFreeAll((FreeAllTag)tag);
				//	break;

				//case TagType.DefineText2:
				//	ParseDefineText2((DefineText2Tag)tag);
				//	break;

				//case TagType.DefineButton2:
				//	ParseDefineButton2((DefineButton2Tag)tag);
				//	break;

				//case TagType.DefineSprite:
				//	ParseDefineSprite((DefineSpriteTag)tag);
				//	break;

				//case TagType.NameCharacter:
				//	ParseNameCharacter((NameCharacterTag)tag);
				//	break;

				//case TagType.SerialNumber:
				//	ParseSerialNumber((SerialNumberTag)tag);
				//	break;

				//case TagType.DefineTextFormat:
				//	ParseDefineTextFormat((DefineTextFormatTag)tag);
				//	break;

				//case TagType.SoundStreamHead2:
				//	ParseSoundStreamHead2((SoundStreamHead2Tag)tag);
				//	break;

				//case TagType.DefineMorphShape:
				//	ParseDefineMorphShape((DefineMorphShapeTag)tag);
				//	break;

				//case TagType.FrameTag:
				//	ParseFrameTag((FrameTagTag)tag);
				//	break;

				//case TagType.DefineFont2:
				//	ParseDefineFont2((DefineFont2Tag)tag);
				//	break;

				//case TagType.GenCommand:
				//	ParseGenCommand((GenCommandTag)tag);
				//	break;

				//case TagType.DefineCommandObj:
				//	ParseDefineCommandObj((DefineCommandObjTag)tag);
				//	break;

				//case TagType.CharacterSet:
				//	ParseCharacterSet((CharacterSetTag)tag);
				//	break;

				//case TagType.FontRef:
				//	ParseFontRef((FontRefTag)tag);
				//	break;

				//case TagType.ImportAssets:
				//	ParseImportAssets((ImportAssetsTag)tag);
				//	break;

				//case TagType.EnableDebugger:
				//	ParseEnableDebugger((EnableDebuggerTag)tag);
				//	break;

				//case TagType.EnableDebugger2:
				//	ParseEnableDebugger2((EnableDebugger2Tag)tag);
				//	break;

				//case TagType.ScriptLimits:
				//	ParseScriptLimits((ScriptLimitsTag)tag);
				//	break;

				//case TagType.SetTabIndex:
				//	ParseSetTabIndex((SetTabIndexTag)tag);
				//	break;

				//case TagType.DefineEditText:
				//	ParseDefineEditText((DefineEditTextTag)tag);
				//	break;

				//case TagType.DefineVideo:
				//	ParseDefineVideo((DefineVideoTag)tag);
				//	break;

				//case TagType.FreeCharacter:
				//	ParseFreeCharacter((FreeCharacterTag)tag);
				//	break;

				//case TagType.PlaceObject:
				//	ParsePlaceObject((PlaceObjectTag)tag);
				//	break;

				//case TagType.RemoveObject:
				//	ParseRemoveObject((RemoveObjectTag)tag);
				//	break;

				//case TagType.DefineButton:
				//	ParseDefineButton((DefineButtonTag)tag);
				//	break;



				//case TagType.DefineFont:
				//	ParseDefineFont((DefineFontTag)tag);
				//	break;

				//case TagType.DefineText:
				//	ParseDefineText((DefineTextTag)tag);
				//	break;

				//case TagType.DoAction:
				//	ParseDoAction((DoActionTag)tag);
				//	break;

				//case TagType.DefineFontInfo:
				//	ParseDefineFontInfo((DefineFontInfoTag)tag);
				//	break;

				//case TagType.DefineSound:
				//	ParseDefineSound((DefineSoundTag)tag);
				//	break;

				//case TagType.StartSound:
				//	ParseStartSound((StartSoundTag)tag);
				//	break;

				//case TagType.DefineButtonSound:
				//	ParseDefineButtonSound((DefineButtonSoundTag)tag);
				//	break;

				//case TagType.SoundStreamHead:
				//	ParseSoundStreamHead((SoundStreamHeadTag)tag);
				//	break;



			}
		}
Exemple #6
0
 protected virtual void UnhandledTag(ISwfTag tag, ISystemServices services)
 {
     services.Log("Unhandled tag '{0}' inside {1}!", tag.ToString(), GetType().Name);
 }
Exemple #7
0
        private void ParseTag(ISwfTag tag)
        {
            switch (tag.TagType)
            {
            case TagType.DefineSprite:
                ParseDefineSpriteTag((DefineSpriteTag)tag);
                break;

            case TagType.DefineShape:
                ParseDefineShapeTag((DefineShapeTag)tag);
                break;

            case TagType.DefineShape2:
                ParseDefineShape2Tag((DefineShape2Tag)tag);
                break;

            case TagType.DefineShape3:
                ParseDefineShape3Tag((DefineShape3Tag)tag);
                break;

            case TagType.DefineShape4:
                ParseDefineShape4Tag((DefineShape4Tag)tag);
                break;

            case TagType.JPEGTables:
                // not retained
                break;

            case TagType.DefineBits:
                ParseDefineBits((DefineBitsTag)tag);
                break;

            case TagType.DefineBitsJPEG2:
                ParseDefineBits((DefineBitsTag)tag);
                break;

            case TagType.DefineBitsJPEG3:
                ParseDefineBits((DefineBitsTag)tag);
                break;

            case TagType.DefineBitsLossless:
                ParseDefineBitsLossless((DefineBitsLosslessTag)tag);
                break;

            case TagType.DefineBitsLossless2:
                if (!addedFullBitmap)
                {
                    addedFullBitmap = true;
                    DefineBitsLosslessTag t = (DefineBitsLosslessTag)tag;
                    fullBitmapId = t.CharacterId;
                    //DefineBitsLosslessTag t = new DefineBitsLosslessTag(true);
                    //t.CharacterId = ot.CharacterId;
                    //t.BitmapFormat = ot.BitmapFormat;
                    t.Width         = (uint)fullBitmap.Bitmap.Width;
                    t.Height        = (uint)fullBitmap.Bitmap.Height;
                    t.OrgBitmapData = null;
                    uint   pxCount = t.Width * t.Height;
                    RGBA[] pxs     = new RGBA[pxCount];

                    fullBitmap.LockBitmap();
                    for (int i = 0; i < pxCount; i++)
                    {
                        int       x  = (int)(i % t.Width);
                        int       y  = (int)(Math.Floor((double)(i / t.Width)));
                        PixelData pd = fullBitmap.GetPixel(x, y);
                        pxs[i] = new RGBA(pd.red, pd.green, pd.blue, pd.alpha);
                    }
                    t.BitmapData = pxs;
                    fullBitmap.UnlockBitmap();
                }
                break;

            case TagType.UnsupportedDefinition:
                break;
            }
        }