Пример #1
0
        SwfChunk ReadChunk()
        {
            if (m_input.Read(m_buffer, 0, 2) != 2)
            {
                return(null);
            }
            int   length = m_buffer.ToUInt16(0);
            Types id     = (Types)(length >> 6);

            length &= 0x3F;
            if (0x3F == length)
            {
                length = m_input.ReadInt32();
            }
            if (Types.DefineSprite == id)
            {
                length = 4;
            }
            var chunk = new SwfChunk(id, length);

            if (length > 0)
            {
                if (m_input.Read(chunk.Data, 0, length) < length)
                {
                    return(null);
                }
            }
            return(chunk);
        }
Пример #2
0
        IImageDecoder OpenBitsJpeg(SwfChunk chunk)
        {
            int jpeg_pos = 0;

            for (int i = 0; i < chunk.Data.Length - 2; ++i)
            {
                if (chunk.Data[i] == 0xFF && chunk.Data[i + 1] == 0xD8)
                {
                    jpeg_pos = i;
                    break;
                }
            }
            var input = new BinMemoryStream(chunk.Data, jpeg_pos, chunk.Data.Length - jpeg_pos);

            return(ImageFormatDecoder.Create(input));
        }
Пример #3
0
        public LosslessImageDecoder(SwfChunk chunk) : base(new BinMemoryStream(chunk.Data))
        {
            m_type = chunk.Type;
            byte format = chunk.Data[2];
            int  bpp;

            switch (format)
            {
            case 3:
                bpp = 8; Format = PixelFormats.Indexed8;
                break;

            case 4:
                bpp = 16; Format = PixelFormats.Bgr565;
                break;

            case 5:
                bpp    = 32;
                Format = HasAlpha ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
                break;

            default: throw new InvalidFormatException();
            }
            uint width  = chunk.Data.ToUInt16(3);
            uint height = chunk.Data.ToUInt16(5);

            m_colors   = 0;
            m_data_pos = 7;
            if (3 == format)
            {
                m_colors = chunk.Data[m_data_pos++] + 1;
            }
            Info = new ImageMetaData {
                Width = width, Height = height, BPP = bpp
            };
        }
Пример #4
0
 public SwfJpeg3Decoder(SwfChunk chunk)
 {
     m_input       = chunk.Data;
     m_jpeg_length = m_input.ToInt32(2);
 }
Пример #5
0
 public SwfJpeg2Decoder(SwfChunk chunk)
 {
     m_input = chunk.Data;
 }
Пример #6
0
 internal static bool IsSoundStream(SwfChunk chunk)
 {
     return(chunk.Type == Types.SoundStreamHead ||
            chunk.Type == Types.SoundStreamHead2 ||
            chunk.Type == Types.SoundStreamBlock);
 }