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


C# ByteBuffer.GetShort方法代码示例

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


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

示例1: ByteBuffer_GetShortReturnsCorrectData

 public void ByteBuffer_GetShortReturnsCorrectData()
 {
     var buffer = new byte[2];
     buffer[0] = 1;
     buffer[1] = 0;
     var uut = new ByteBuffer(buffer);
     Assert.AreEqual(1, uut.GetShort(0));
 }
开发者ID:google,项目名称:flatbuffers,代码行数:8,代码来源:ByteBufferTests.cs

示例2: Decode

        /* Decode Spotify OGG header. */
        private void Decode(byte[] header)
        {
            /* Get input steam of bytes. */
            ByteBuffer input = new ByteBuffer(header);

            /* Skip OGG page header (length is always 0x1C in this case). */
            input.Position = 0x1C;

            /* Read Spotify specific data. */
            if (input.GetByte() == 0x81)
            {
                while (input.Remaining >= 2)
                {
                    int blockSize = this.Swap(input.GetShort());

                    if (input.Remaining >= blockSize && blockSize > 0)
                    {
                        switch (input.GetByte())
                        {
                            /* Table lookup */
                            case 0:
                                if (blockSize == 0x6e)
                                {
                                    this.Samples = this.Swap(input.GetInt());
                                    this.Size  = this.Swap(input.GetInt());
                                    this._unknown = -this._headerTableDec[input.GetByte()];
                                    this.Table   = new int[0x64];

                                    int ack = this._unknown;
                                    int ctr = 0;

                                    for (int i = 0; i < 0x64; i++)
                                    {
                                        ack += this._headerTableDec[input.GetByte()];

                                        this.Table[ctr] = ack;
                                    }
                                }

                                break;
                            /* Gain */
                            case 1:
                                if(blockSize > 0x10)
                                {
                                    this.GainDb = 1.0f;

                                    int value;

                                    if ((value = this.Swap(input.GetInt())) != -1)
                                    {
                                        this.GainDb = FloatUtils.CreateFromIntBits(value);
                                    }

                                    if (this.GainDb < -40.0f)
                                    {
                                        this.GainDb = 0.0f;
                                    }

                                    this.GainScale = this.GainDb * 0.05f;
                                    this.GainScale = (Single)Math.Pow(10.0, this.GainScale);
                                }

                                break;
                        }
                    }
                }
            }
        }
开发者ID:heksesang,项目名称:sharpotify,代码行数:69,代码来源:SpotifyOggHeader.cs

示例3: ByteBuffer_GetShortChecksOffset

 public void ByteBuffer_GetShortChecksOffset()
 {
     var buffer = new byte[2];
     var uut = new ByteBuffer(buffer);
     Assert.Throws<ArgumentOutOfRangeException>(() => uut.GetShort(2));
 }
开发者ID:google,项目名称:flatbuffers,代码行数:6,代码来源:ByteBufferTests.cs

示例4: testHet

        private static void testHet(int level, ByteBuffer b)
        {

            int p = b.Position;
            b.Limit = (b.Capacity);
            Show(level, b);
            output.Write("    put:");

            b.PutChar((char)1);
            b.PutChar((char)char.MaxValue);
            output.Write(" char");

            b.PutShort((short)1);
            b.PutShort((short)short.MaxValue);
            output.Write(" short");

            b.PutInt(1);
            b.PutInt(int.MaxValue);
            output.Write(" int");

            b.PutLong((long)1);
            b.PutLong((long)long.MaxValue);
            output.Write(" long");

            b.PutFloat((float)1);
            b.PutFloat((float)float.MinValue);
            b.PutFloat((float)float.MaxValue);
            output.Write(" float");

            b.PutDouble((double)1);
            b.PutDouble((double)double.MinValue);
            b.PutDouble((double)double.MaxValue);
            output.Write(" double");

            output.WriteLine();
            b.Limit = (b.Position);
            b.Position = (p);
            Show(level, b);
            output.Write("    get:");

            ck(b, b.GetChar(), 1);
            ck(b, b.GetChar(), char.MaxValue);
            output.Write(" char");

            ck(b, b.GetShort(), 1);
            ck(b, b.GetShort(), short.MaxValue);
            output.Write(" short");

            ck(b, b.GetInt(), 1);
            ck(b, b.GetInt(), int.MaxValue);
            output.Write(" int");

            ck(b, b.GetLong(), 1);
            ck(b, b.GetLong(), long.MaxValue);
            output.Write(" long");

            ck(b, (long)b.GetFloat(), 1);
            ck(b, (long)b.GetFloat(), unchecked((long)float.MinValue));
            ck(b, (long)b.GetFloat(), unchecked((long)float.MaxValue));
            output.Write(" float");

            ck(b, (long)b.GetDouble(), 1);
            ck(b, (long)b.GetDouble(), unchecked((long)double.MinValue));
            ck(b, (long)b.GetDouble(), unchecked((long)double.MaxValue));
            output.Write(" double");

            output.WriteLine();
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:68,代码来源:TestByteBuffer.cs


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