Ejemplo n.º 1
0
        private void  encodeBranch(Branch branch)
        {
            writer.writeUI8(branch.code);
            writer.writeUI16(2);
            int pos = writer.Pos;

            if (labels.ContainsKey(branch.target))
            {
                // label came earlier
                writer.writeSI16(getLabelOffset(branch.target) - pos - 2);
            }
            else
            {
                // label comes later. don't know the offset yet.
                updates.Add(new UpdateEntry(pos + 2, pos, branch));
                writer.writeSI16(0);
            }
        }
Ejemplo n.º 2
0
		private void  encodeTextRecord(TextRecord record, SwfEncoder w, int type, int glyphBits, int advanceBits)
		{
			w.writeUI8(record.flags);
			
			if (record.hasFont())
			{
				w.writeUI16(dict.getId(record.font));
			}
			
			if (record.hasColor())
			{
				if (type == flash.swf.TagValues_Fields.stagDefineText2)
					encodeRGBA(record.color, w);
				else
					encodeRGB(record.color, w);
			}
			
			if (record.hasX())
			{
				w.writeSI16(record.xOffset);
			}
			
			if (record.hasY())
			{
				w.writeSI16(record.yOffset);
			}
			
			if (record.hasHeight())
			{
				w.writeUI16(record.height);
			}
			
			w.writeUI8(record.entries.Length);
			
			for (int i = 0; i < record.entries.Length; i++)
			{
				w.writeUBits(record.entries[i].Index, glyphBits);
				w.writeSBits(record.entries[i].advance, advanceBits);
			}
			w.flushBits();
		}
Ejemplo n.º 3
0
		private void  encodeMorphFillstyle(MorphFillStyle style, SwfEncoder w, int code)
		{
			w.writeUI8(style.type);
			switch (style.type)
			{
				
				case FillStyle.FILL_SOLID:  // 0x00
					encodeRGBA(style.startColor, w);
					encodeRGBA(style.endColor, w);
					break;
				
				case FillStyle.FILL_GRADIENT: 
				// 0x10 linear gradient fill
				case FillStyle.FILL_RADIAL_GRADIENT: 
				// 0x12 radial gradient fill
				case FillStyle.FILL_FOCAL_RADIAL_GRADIENT:  // 0x13 focal radial gradient fill
					encodeMatrix(style.startGradientMatrix, w);
					encodeMatrix(style.endGradientMatrix, w);
					encodeMorphGradient(style.gradRecords, w);
					if (style.type == FillStyle.FILL_FOCAL_RADIAL_GRADIENT && code == flash.swf.TagValues_Fields.stagDefineMorphShape2)
					{
						w.writeSI16(style.ratio1);
						w.writeSI16(style.ratio2);
					}
					break;
				
				case FillStyle.FILL_BITS: 
				// 0x40 tiled bitmap fill
				case (FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP): 
				// 0x41 clipped bitmap fill
				case (FillStyle.FILL_BITS | FillStyle.FILL_BITS_NOSMOOTH): 
				// 0x42 tiled non-smoothed fill
				case (FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP | FillStyle.FILL_BITS_NOSMOOTH):  // 0x43 clipped non-smoothed fill
					w.writeUI16(dict.getId(style.bitmap));
					encodeMatrix(style.startBitmapMatrix, w);
					encodeMatrix(style.endBitmapMatrix, w);
					break;
				
				default: 
					assert(false);
					//throw new IOException("unrecognized fill style type: " + style.type);
					break;
				
			}
		}