Exemple #1
0
        public override bool Equals(System.Object object_Renamed)
        {
            bool isEqual = false;

            if (base.Equals(object_Renamed) && (object_Renamed is DefineBitsLossless))
            {
                DefineBitsLossless defineBitsLossless = (DefineBitsLossless)object_Renamed;

                if ((defineBitsLossless.format == this.format) && (defineBitsLossless.width == this.width) && (defineBitsLossless.height == this.height) && ArrayUtil.equals(defineBitsLossless.colorData, this.colorData))
                {
                    isEqual = true;
                }
            }

            return(isEqual);
        }
		public override void  defineBitsLossless2(DefineBitsLossless tag)
		{
			tags.Add(tag);
		}
		public virtual void  defineBitsLossless2(DefineBitsLossless tag)
		{
		}
		private void  decodeColorMapData(SwfDecoder r1, DefineBitsLossless tag, int tableSize)
		{
			tag.colorData = new int[tableSize];
			
			for (int i = 0; i < tableSize; i++)
			{
				tag.colorData[i] = decodeRGB(r1);
			}
			
			int width = tag.width;
			int height = tag.height;
			
			if (width % 4 != 0)
			{
				width = (width / 4 + 1) * 4;
			}
			
			tag.data = new byte[width * height];
			
			r1.readFully(tag.data);
		}
		private Tag decodeDefineBitsLossless(int length)
		{
			DefineBitsLossless t = new DefineBitsLossless(Flash.Swf.TagValues.stagDefineBitsLossless);
			SwfDecoder r1 = r;
			
			int pos = r1.Offset;
			
			int id = r1.readUI16();
			t.format = r1.readUI8();
			t.width = r1.readUI16();
			t.height = r1.readUI16();
			
			byte[] data;
			
			switch (t.format)
			{
				
				case 3: 
					int tableSize = r1.readUI8() + 1;
					length -= (r1.Offset - pos);
					data = new byte[length];
					r1.readFully(data);
					r1 = new SwfDecoder(new DeflateStream(new MemoryStream(data), CompressionMode.Decompress, true), SwfVersion);
					decodeColorMapData(r1, t, tableSize);
					break;
				
				case 4: 
				case 5: 
					length -= (r1.Offset - pos);
					data = new byte[length];
					r1.readFully(data);
					r1 = new SwfDecoder(new DeflateStream(new MemoryStream(data), CompressionMode.Decompress, true), SwfVersion);
					t.data = new byte[t.width * t.height * 4];
					r1.readFully(t.data);
					break;
				
				default: 
					throw new SwfFormatException("Illegal bitmap format " + t.format);
				
			}
			
			dict.add(id, t);
			return t;
		}
		private void  decodeAlphaColorMapData(SwfDecoder r1, DefineBitsLossless tag, int tableSize)
		{
			int width = tag.width;
			int height = tag.height;
			
			tag.colorData = new int[tableSize];
			
			for (int i = 0; i < tableSize; i++)
			{
				tag.colorData[i] = decodeRGBA(r1);
			}
			
			if (width % 4 != 0)
			{
				width = (width / 4 + 1) * 4;
			}
			
			int data_size = width * height;
			
			tag.data = new byte[data_size];
			//r1.read(tag.data);
			
			int i2 = 0;
			int b;
			while (i2 < data_size)
			{
				b = r1.readUI8();
				if (b != - 1)
				{
					tag.data[i2] = (byte) b;
					i2++;
				}
				else
				{
					break;
				}
			}
			
			int extra = 0;
			while (r1.readUI8() != -1)
			{
				extra++;
			}
			
			if (extra > 0)
			{
				throw new SwfFormatException(extra + " bytes of bitmap data (" + width + "x" + height + ") not read!");
			}
			else if (i2 != data_size)
			{
				throw new SwfFormatException("(" + width + "x" + height + ") data buffer " + (data_size - i2) + " bytes too big...");
			}
		}