当前位置: 首页>>代码示例>>C#>>正文


C# Stream.ReadUInt方法代码示例

本文整理汇总了C#中Stream.ReadUInt方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadUInt方法的具体用法?C# Stream.ReadUInt怎么用?C# Stream.ReadUInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stream的用法示例。


在下文中一共展示了Stream.ReadUInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFileList

        /* Get the offsets, lengths, and filenames of all the files */
        public override ArchiveFileList GetFileList(ref Stream data)
        {
            try
            {
                /* Get the number of files */
                uint files = data.ReadUInt(0x0);

                /* Create the array of files now */
                ArchiveFileList fileList = new ArchiveFileList(files);

                /* Now we can get the file offsets, lengths, and filenames */
                for (uint i = 0; i < files; i++)
                {
                    fileList.Entries[i] = new ArchiveFileList.Entry(
                        data.ReadUInt(0x4 + (i * 0x2C)), // Offset
                        data.ReadUInt(0x8 + (i * 0x2C)), // Length
                        data.ReadString(0xC + (i * 0x2C), 36) // Filename
                    );
                }

                return fileList;
            }
            catch
            {
                return null;
            }
        }
开发者ID:memerdot,项目名称:puyotools,代码行数:28,代码来源:sba.cs

示例2: Check

 /* Checks to see if the input stream is a Storybook archive */
 public override bool Check(ref Stream input, string filename)
 {
     try
     {
         return (input.ReadUInt(0x4).SwapEndian() == 0x10 &&
            (input.ReadUInt(0xC).SwapEndian() == 0xFFFFFFFF ||
             input.ReadUInt(0xC).SwapEndian() == 0x00000000));
     }
     catch
     {
         return false;
     }
 }
开发者ID:memerdot,项目名称:puyotools,代码行数:14,代码来源:sba.cs

示例3: Check

 /* Checks to see if the input stream is a MRG archive */
 public override bool Check(ref Stream input, string filename)
 {
     try
     {
         return (input.ReadString(0x0, 4) == ArchiveHeader.TEX &&
             input.ReadUInt(0x4) != input.Length &&
             input.ReadUInt(0x4) != input.Length - 4);
     }
     catch
     {
         return false;
     }
 }
开发者ID:memerdot,项目名称:puyotools,代码行数:14,代码来源:tex.cs

示例4: Destream

 public static HashBlock[] Destream(Stream inputStream)
 {
     uint count = inputStream.ReadUInt();
     var hashBlocks = new HashBlock[count];
     for (int i = 0; i < count; ++i)
     {
         hashBlocks[i] = new HashBlock {Hash = new byte[16]};
         inputStream.Read(hashBlocks[i].Hash, 0, 16);
         hashBlocks[i].Length = inputStream.ReadInt();
         hashBlocks[i].Offset = inputStream.ReadLong();
         hashBlocks[i].Checksum = inputStream.ReadUInt();
     }
     return hashBlocks;
 }
开发者ID:billybit,项目名称:RsyncNet,代码行数:14,代码来源:HashBlockStreamer.cs

示例5: VideoHandler

 protected override void VideoHandler(Stream packet)
 {
     var time = packet.ReadUInt();
     var length = (uint)packet.GetAvaliableByteCounts();
     if (_numberLostFragments > 0)
         _firstKeyFrame = false;
     if ((packet.ReadByte() & 0xF0) == 0x10)
         _firstKeyFrame = true;
     packet.Position--;
     if (!_firstKeyFrame)
     {
         //丢失关键帧
         return;
     }
     _numberLostFragments = 0;
     if (_publisher != null && _publisher.PublisherId == StreamId)
     {
         //_publication.PushVideoPacket(packet.ReadUInt32(),packet,_numberLostFragments);
         _publisher.FeedData(packet, length, 0, length, time, false);
     }
     else if (OutStream != null)
     {
         TotalBytes += length;
         OutStream.FeedData(packet, length, 0, length, time, false);
     }
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:26,代码来源:FlowStream.cs

示例6: AudioHandler

 protected override void AudioHandler(Stream packet)
 {
     if (_publisher != null && _publisher.PublisherId == StreamId)
     {
         var time = packet.ReadUInt();
         var length = (uint)packet.GetAvaliableByteCounts();
        // _publication.PushAudioPacket(packet.ReadUInt32(), packet, _numberLostFragments);
         _publisher.FeedData(packet, length, 0, length, time, true);
         _numberLostFragments = 0;
     }else if (OutStream != null)
     {
         var time = packet.ReadUInt();
         var length = (uint)packet.GetAvaliableByteCounts();
         TotalBytes += length;
         OutStream.FeedData(packet, length, 0, length, time, true);
     }
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:17,代码来源:FlowStream.cs

示例7: LoadFrom

 public virtual bool LoadFrom(Stream stream)
 {
     uint count = stream.ReadUInt();
     for (int i = 0; i < count; i++)
     {
         var key = stream.ReadString();
         var val = stream.ReadString();
         KeyValues.Add(key, val);
     }
     return true;
 }
开发者ID:fjz13,项目名称:Medusa,代码行数:11,代码来源:BaseSirenAttribute.cs

示例8: SendStream

 public override void SendStream(Stream stream,int length)
 {
     var marker = stream.ReadByte() | 0xF0;
     var echoTime = marker == (Target == null ? 0xFE : 0xFD);
     stream.ReadUShort();
     if (echoTime) stream.ReadUShort();
     var type = stream.ReadByte();
     if (type == 0x10)
     {
         var sizePos = stream.Position;
         var size = stream.ReadUShort();
         var flags = stream.ReadByte();
         var idFlow = stream.Read7BitLongValue();
         var stage = stream.Read7BitLongValue();
         if (idFlow == 2 && stage == 1)
         {
             var deltaNAck = stream.Read7BitLongValue();
             var len = (ushort) stream.ReadByte();
             stream.Position += len;
             stream.ReadByte();
             stream.ReadByte();//type
             stream.ReadUInt();//timestamp
             var amfReader = new AMF0Reader(stream);
             var str = amfReader.ReadShortString(true);
             var num = amfReader.ReadAMFDouble(true);
             var pos = stream.Position;
             var connectionInfo = amfReader.ReadVariant();
             connectionInfo["tcUrl"] = MiddleSession.QueryUrl;
             connectionInfo["app"] = MiddleSession.QueryUrl.Split('/').Last();
             stream.Position = pos;
             var amfWriter = new AMF0Writer(stream);
             amfWriter.WriteObject(connectionInfo, true);
             length = (int) stream.Position;
             len = (ushort) (stream.Position - sizePos-2);
             stream.Position = sizePos;
             stream.Write(len);
         }
     }
     stream.Position = 6;
     base.SendStream(stream,length);
 }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:41,代码来源:Middle.cs

示例9: DecodeFrame

        public Bitmap DecodeFrame(int frameIndex, Stream inStream)
        {
            if (inStream == null) return null;

            try
            {
                // Check the frame header:
                if (inStream.ReadUInt() != MAGIC_FRAME) return null;

                int encodedFrameIndex = inStream.ReadSShort();
                if (encodedFrameIndex != frameIndex) return null;

                BitmapData currentData = currentFrame.LockBits(
                    new Rectangle(0, 0, frameWidth, frameHeight),
                    ImageLockMode.ReadOnly, currentFrame.PixelFormat);
                BitmapData previousData = previousFrame.LockBits(
                    new Rectangle(0, 0, frameWidth, frameHeight),
                    ImageLockMode.ReadOnly, previousFrame.PixelFormat);

                if (VisualizeMCBlockTypes)
                {
                    debugFrame = new Bitmap(frameWidth, frameHeight, PixelFormat.Format24bppRgb);
                    debugFrameData = debugFrame.LockBits(
                        new Rectangle(0, 0, frameWidth, frameHeight),
                        ImageLockMode.ReadOnly, debugFrame.PixelFormat);
                }

                int pixelBytes = GetBytesPerPixel(currentFrame.PixelFormat);

                // TODO: handle bad value
                FrameType frameType = (FrameType)inStream.ReadUByte();
                switch (frameType)
                {
                    case FrameType.Intra:
                        DecodeIntraFrame(inStream, currentData, pixelBytes);
                        break;
                    case FrameType.Predicted:
                        DecodePredictedFrame(inStream, currentData, previousData, pixelBytes);
                        break;
                }

                currentFrame.UnlockBits(currentData);
                previousFrame.UnlockBits(previousData);

                if (VisualizeMCBlockTypes)
                {
                    debugFrame.UnlockBits(debugFrameData);
                    debugFrame.Save(String.Format("debug{0:000000}.png", frameIndex), ImageFormat.Png);
                    debugFrame.Dispose();
                }
            }
            catch (EndOfStreamException ex)
            {
                Log("Exception: {0} {1}", ex.Message, ex.StackTrace);
                return null;
            }

            Bitmap result = currentFrame;
            // double buffering
            // save the current bitmap to act as previous one when decoding the next frame
            SwapBitmaps(ref previousFrame, ref currentFrame);
            //currentFrame.Dispose();

            return result;
        }
开发者ID:bzamecnik,项目名称:grcis,代码行数:65,代码来源:VideoCodec.cs

示例10: Decompress

        /* Decompress */
        public override MemoryStream Decompress(ref Stream data)
        {
            try
            {
                // Compressed & Decompressed Data Information
                uint CompressedSize   = data.ReadUInt(0x4);
                uint DecompressedSize = data.ReadUInt(0x8);

                byte[] CompressedData   = data.ToByteArray();
                byte[] DecompressedData = new byte[DecompressedSize];
                byte[] DestBuffer       = new byte[0x1000];

                uint SourcePointer = 0x10;
                uint DestPointer   = 0x0;
                uint BufferPointer = 0xFEE;

                // Start Decompression
                while (SourcePointer < CompressedSize && DestPointer < DecompressedSize)
                {
                    byte Flag = CompressedData[SourcePointer]; // Compression Flag
                    SourcePointer++;

                    for (int i = 0; i < 8; i++)
                    {
                        if ((Flag & (1 << i)) > 0) // Data is not compressed
                        {
                            DecompressedData[DestPointer] = CompressedData[SourcePointer];
                            DestBuffer[BufferPointer]     = DecompressedData[DestPointer];
                            SourcePointer++;
                            DestPointer++;
                            BufferPointer = (BufferPointer + 1) & 0xFFF;
                        }
                        else // Data is compressed
                        {
                            int Offset = ((((CompressedData[SourcePointer + 1] >> 4) & 0xF) << 8) | CompressedData[SourcePointer]);
                            int Amount = (CompressedData[SourcePointer + 1] & 0xF) + 3;
                            SourcePointer += 2;

                            for (int j = 0; j < Amount; j++)
                            {
                                DecompressedData[DestPointer + j] = DestBuffer[(Offset + j) & 0xFFF];
                                DestBuffer[BufferPointer]         = DecompressedData[DestPointer + j];
                                BufferPointer = (BufferPointer + 1) & 0xFFF;
                            }
                            DestPointer += (uint)Amount;
                        }

                        // Check for out of range
                        if (SourcePointer >= CompressedSize || DestPointer >= DecompressedSize)
                            break;
                    }
                }

                return new MemoryStream(DecompressedData);
            }
            catch
            {
                return null; // An error occured while decompressing
            }
        }
开发者ID:memerdot,项目名称:puyotools,代码行数:61,代码来源:lz01.cs

示例11: GetFileList

        /* Get the offsets, lengths, and filenames of all the files */
        public override ArchiveFileList GetFileList(ref Stream data)
        {
            try
            {
                /* Get the number of files */
                ushort files = data.ReadUShort(0x0);

                /* Create the array of files now */
                ArchiveFileList fileList = new ArchiveFileList(files);

                /* Now we can get the file offsets, lengths, and filenames */
                for (int i = 0; i < files; i++)
                {
                    /* Get the filename */
                    string filename = data.ReadString(0xA + (i * 0x24), 28);

                    fileList.Entries[i] = new ArchiveFileList.Entry(
                        data.ReadUInt(0x2 + (i * 0x24)), // Offset
                        data.ReadUInt(0x6 + (i * 0x24)), // Length
                        (filename == String.Empty ? String.Empty : filename + (filename.IsAllUpperCase() ? ".PVR" : ".pvr")) // Filename
                    );
                }

                return fileList;
            }
            catch
            {
                /* Something went wrong, so return nothing */
                return null;
            }
        }
开发者ID:memerdot,项目名称:puyotools,代码行数:32,代码来源:pvm.cs

示例12: LoadFrom

        public override bool LoadFrom(Stream stream)
        {
            base.LoadFrom(stream);
            Attribute.LoadFrom(stream);
            BaseTypeName = stream.ReadString();

            //types
            uint typeCount = stream.ReadUInt();
            for (int i = 0; i < typeCount; i++)
            {
                byte isClass = (byte)stream.ReadByte();
                if (isClass == 1)
                {
                    SirenCustomClass type = new SirenCustomClass();
                    type.LoadFrom(stream);
                    type.Parent = this;
                    Types.Add(type.Name, type);
                }
                else
                {
                    SirenCustomEnum type = new SirenCustomEnum();
                    type.LoadFrom(stream);
                    type.Parent = this;
                    Types.Add(type.Name, type);
                }
            }
            //fields
            uint fieldCount = stream.ReadUInt();
            for (int i = 0; i < fieldCount; i++)
            {
                SirenField field = new SirenField();
                field.LoadFrom(stream);
                field.ParentType = this;
                FieldNameDict.Add(field.Name, field);
                field.Index = (ushort)(FieldNameDict.Count - 1);
            }

            return true;
        }
开发者ID:fjz13,项目名称:Medusa,代码行数:39,代码来源:SirenCustomClass.cs

示例13: GetFileList

        /* Get the offsets, lengths, and filenames of all the files */
        public override ArchiveFileList GetFileList(ref Stream data)
        {
            try
            {
                /* Get the number of files */
                uint files = data.ReadUInt(0x30);

                /* Create the array of files now */
                ArchiveFileList fileList = new ArchiveFileList(files);

                /* See if the archive contains filenames */
                bool containsFilenames = (files > 0 && data.ReadUInt(0x3C + (files * 0x14)) + 0x20 != 0x3C + (files * 0x1C) && data.ReadString(0x3C + (files * 0x1C), 4) == "FLST");

                /* Now we can get the file offsets, lengths, and filenames */
                for (uint i = 0; i < files; i++)
                {
                    /* Get the offset & length */
                    uint offset = data.ReadUInt(0x40 + (files * 0x14) + (i * 0x8)) + 0x20;
                    uint length = data.ReadUInt(0x3C + (files * 0x14) + (i * 0x8));

                    /* Check for filenames */
                    string filename = String.Empty;
                    if (containsFilenames)
                        filename = data.ReadString(0x40 + (files * 0x1C) + (i * 0x40), 64);

                    /* GIM files can also contain their original filename in the footer */
                    if (filename == string.Empty && length > 40 && data.ReadString(offset, 12, false) == GraphicHeader.MIG)
                    {
                        uint filenameOffset = data.ReadUInt(offset + 0x24) + 0x30;
                        if (filenameOffset < length)
                            filename = Path.GetFileNameWithoutExtension(data.ReadString(offset + filenameOffset, (int)(length - filenameOffset)));

                        if (filename != String.Empty)
                            filename += (filename.IsAllUpperCase() ? ".GIM" : ".gim");
                    }

                    fileList.Entries[i] = new ArchiveFileList.Entry(
                        offset,  // Offset
                        length,  // Length
                        filename // Filename
                    );
                }

                return fileList;
            }
            catch
            {
                /* Something went wrong, so return nothing */
                return null;
            }
        }
开发者ID:memerdot,项目名称:puyotools,代码行数:52,代码来源:snt.cs

示例14: GetFileList

        /* Get the offsets, lengths, and filenames of all the files */
        public override ArchiveFileList GetFileList(ref Stream data)
        {
            try
            {
                /* Get the number of files */
                uint files = data.ReadUInt(0x4).SwapEndian();

                /* Create the array of files now */
                ArchiveFileList fileList = new ArchiveFileList(files);

                /* Now we can get the file offsets, lengths, and filenames */
                for (uint i = 0; i < files; i++)
                {
                    string filename = data.ReadString(0x10 + (i * 0x28), 32);

                    fileList.Entries[i] = new ArchiveFileList.Entry(
                        data.ReadUInt(0x08 + (i * 0x28)).SwapEndian(), // Offset
                        data.ReadUInt(0x0C + (i * 0x28)).SwapEndian(), // Length
                        (filename == String.Empty ? String.Empty : filename + (filename.IsAllUpperCase() ? ".GVR" : ".gvr")) // Filename
                    );
                }

                return fileList;
            }
            catch
            {
                /* Something went wrong, so return nothing */
                return null;
            }
        }
开发者ID:memerdot,项目名称:puyotools,代码行数:31,代码来源:txag.cs

示例15: TranslateData

        /* To simplify the process greatly, we are going to convert
         * the GVM to a new format */
        public override MemoryStream TranslateData(ref Stream stream)
        {
            try
            {
                /* Get the number of files, and format type in the stream */
                ushort files = stream.ReadUShort(0xA).SwapEndian();
                byte formatType = stream.ReadByte(0x9);

                /* Now let's see what information is contained inside the metadata */
                bool containsFilename    = (formatType & (1 << 3)) > 0;
                bool containsPixelFormat = (formatType & (1 << 2)) > 0;
                bool containsDimensions  = (formatType & (1 << 1)) > 0;
                bool containsGlobalIndex = (formatType & (1 << 0)) > 0;

                /* Let's figure out the metadata size */
                int size_filename = 0, size_pixelFormat = 0, size_dimensions = 0, size_globalIndex = 0;
                if (containsFilename)    size_filename = 28;
                if (containsPixelFormat) size_pixelFormat = 2;
                if (containsDimensions)  size_dimensions = 2;
                if (containsGlobalIndex) size_globalIndex = 4;
                int metaDataSize = 2 + size_filename + size_pixelFormat + size_dimensions + size_globalIndex;

                /* Now create the header */
                MemoryStream data = new MemoryStream();
                data.Write(files);

                /* Ok, try to find out data */
                uint sourceOffset = stream.ReadUInt(0x4) + 0x8;

                /* Write each file in the header */
                uint offset = 0x2 + ((uint)files * 0x24);
                for (int i = 0; i < files; i++)
                {
                    /* Ok, get the size of the GVR file */
                    uint length = stream.ReadUInt(sourceOffset + 0x4) + 8;

                    /* Make sure this is a valid file length */
                    if (sourceOffset + length > stream.Length)
                        length -= 16; // For some reason some GVR files are like this.
                    if (sourceOffset + length > stream.Length)
                        throw new Exception();

                    /* Write the offset, file length, and filename */
                    data.Write(offset);      // Offset
                    data.Write(length + 16); // Length

                    if (containsFilename)
                        data.Write(stream.ReadString(0xE + (i * metaDataSize), 28), 28); // Filename
                    else
                        data.Position += 28;

                    /* Add the GBIX header */
                    data.Position = offset;
                    data.Write(GraphicHeader.GBIX);
                    data.Write((int)0x8);

                    /* Copy the global index */
                    if (containsGlobalIndex)
                        data.Write(stream.ReadUInt(0xE + size_filename + size_pixelFormat + size_dimensions + (i * metaDataSize)));
                    else
                        data.Position += 4;

                    /* Write out the 0x0 in the header */
                    data.Write(new byte[] { 0x0, 0x0, 0x0, 0x0 });

                    /* Now copy the file */
                    data.Write(stream, sourceOffset, length);
                    data.Position = 0x26 + (i * 0x24);

                    sourceOffset += length.RoundUp(16);

                    /* Increment the offset */
                    offset += length + 16;
                }

                return data;
            }
            catch
            {
                /* Something went wrong, so send as blank stream */
                return new MemoryStream();
            }
        }
开发者ID:memerdot,项目名称:puyotools,代码行数:85,代码来源:gvm.cs


注:本文中的Stream.ReadUInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。