Пример #1
0
        private static void write(Chunk chunk, StreamAccessor accessor)
        {
            accessor.Write(chunk.name, EncodingType.CC4);
            StreamAccessor ac2  = new StreamAccessor(accessor.WriteSubStream(4));
            long           pos0 = accessor.Position;

            // 内容
            if (chunk.content != null)
            {
                if (chunk.content is byte[])
                {
                    accessor.Write((byte[])chunk.content);
                }
                else if (chunk.content is System.IO.Stream)
                {
                    accessor.WriteStream((System.IO.Stream)chunk.content);
                }
                else
                {
                    RiffChunkReadWriteAttribute.Write(chunk.content, accessor);
                }
            }
            else if (chunk._data != null)
            {
                accessor.Write(chunk._data);
            }
            else if (chunk._stream != null)
            {
                accessor.WriteStream(chunk.Stream);
            }

            ac2.Write(checked ((uint)(accessor.Position - pos0)), EncodingType.U4);
            ac2.Stream.Close();
        }
Пример #2
0
        private static void write(DirectoryCollection dirs, StreamAccessor accessor)
        {
            StreamAccessor acSize = new StreamAccessor(accessor.WriteSubStream(4));
            long           pos0   = accessor.Position;

            foreach (ImageDirectory childdir in dirs)
            {
                accessor.Write(childdir);
            }
            acSize.Write(checked ((uint)(accessor.Position - pos0)), EncodingType.U4);
            acSize.Stream.Close();
        }
Пример #3
0
        private void WriteExtHeader(StreamAccessor accessor, out StreamAccessor str_crc32)
        {
            accessor.Write(this.hascrc ? 10 : 6, EncodingType.U4BE);
            ushort num = this.hascrc ? ((ushort)0x8000) : ((ushort)0);

            accessor.Write(num, EncodingType.U2BE);
            accessor.Write((uint)0, EncodingType.U4BE);
            if (this.hascrc)
            {
                str_crc32 = new StreamAccessor(accessor.WriteSubStream(4L));
            }
            else
            {
                str_crc32 = null;
            }
        }
Пример #4
0
        private static void write(RiffFile value, StreamAccessor accessor)
        {
            accessor.Write("RIFF", EncodingType.CC4);

            StreamAccessor acSize = new StreamAccessor(accessor.WriteSubStream(4));
            long           pos0   = accessor.Position;

            accessor.Write(value.type, EncodingType.CC4);
            foreach (Chunk chunk in value.chunks)
            {
                accessor.Write(chunk, EncodingType.NoSpecified);
            }

            uint size = checked ((uint)(accessor.Position - pos0));

            acSize.Write(size, EncodingType.U4);
            acSize.Stream.Close();
        }