예제 #1
0
파일: AniFile.cs 프로젝트: zeta1999/Vrmac
            public void parse(iRiffChunk chunk)
            {
                if (chunk.parentTag == ACON && chunk.tag == ANIH)
                {
                    header = chunk.read <ANIHeader>();
                    if (header.cbSizeOf != Marshal.SizeOf <ANIHeader>())
                    {
                        throw new ArgumentException("ANI header has wrong size");
                    }
                    frames = new Frame[header.cFrames];
                    return;
                }

                if (chunk.parentTag == FRAM && chunk.tag == ICON)
                {
                    if (null == frames)
                    {
                        throw new ArgumentException("ANI header not found");
                    }
                    if (chunk.index >= frames.Length)
                    {
                        throw new ArgumentException("Too many frames in the ANI");
                    }
                    frames[chunk.index] = new Frame(chunk);
                    parsedFrames        = chunk.index + 1;
                    return;
                }
            }
예제 #2
0
        /// <summary>Read a structure from RIFF chunk</summary>
        public static T read <T>(this iRiffChunk chunk) where T : unmanaged
        {
            T result = new T();

            chunk.read(MiscUtils.asSpan(ref result));
            return(result);
        }
예제 #3
0
파일: AniFile.cs 프로젝트: zeta1999/Vrmac
            internal Frame(iRiffChunk chunk)
            {
                var header = chunk.read <ICONDIR>();

                if (header.idReserved != 0)
                {
                    throw new ArgumentException("The stream is not a valid cursor file");
                }

                if (header.idType != eImageType.Cursor)
                {
                    if (header.idType == eImageType.Icon)
                    {
                        throw new ArgumentException("The stream contains an icon, not a cursor");
                    }
                    throw new ArgumentException("The stream is not a valid cursor file");
                }
                if (header.idCount <= 0)
                {
                    throw new ArgumentException("The stream doesn't have any images");
                }

                // Read the directory
                images = new ICONDIRECTORY[header.idCount];
                chunk.read(images);

                // Sort the entries so we don't have to rewind the stream
                Array.Sort(images, (a, b) => a.imageOffset.CompareTo(b.imageOffset));

                // Construct the payloads, and read initial 4 bytes of each image.
                payloads = new Payload[header.idCount];
                for (int i = 0; i < header.idCount; i++)
                {
                    int skipBytes = chunk.chunkOffset + images[i].imageOffset - chunk.currentOffset;
                    chunk.skip(skipBytes);

                    int  offset = chunk.currentOffset;
                    uint hh     = chunk.read <uint>();
                    int  cb     = images[i].sizeInBytes;
                    payloads[i] = new Payload(offset, cb, hh);
                }
            }
예제 #4
0
        /// <summary>Read an array of structures from RIFF chunk</summary>
        public static void read <T>(this iRiffChunk chunk, T[] arr) where T : unmanaged
        {
            var span = MemoryMarshal.Cast <T, byte>(arr.AsSpan());

            chunk.read(span);
        }
예제 #5
0
파일: TestRiff.cs 프로젝트: zeta1999/Vrmac
 static void consumeChunk(iRiffChunk chunk)
 {
     Console.WriteLine(chunk);
 }