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


C# Endianness类代码示例

本文整理汇总了C#中Endianness的典型用法代码示例。如果您正苦于以下问题:C# Endianness类的具体用法?C# Endianness怎么用?C# Endianness使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: RawEncoder

        public RawEncoder(int bufferSize, IMsgSource msgSource, Endianness endianness)
            : base(bufferSize, endianness)
        {
            m_msgSource = msgSource;

            NextStep(null, 0, RawMessageReadyState, true);
        }
开发者ID:JayShelton,项目名称:netmq,代码行数:7,代码来源:RawEncoder.cs

示例2: ReadBytes

        public static byte[] ReadBytes(this BinaryReader binaryReader, Int32 count, Endianness endianness)
        {
            if (endianness == Endianness.Little)
                return binaryReader.ReadBytes(count);

            return binaryReader.ReadBytes(count).Reverse().ToArray();
        }
开发者ID:Kiyiko,项目名称:AlicanC-s-Modern-Warfare-2-Tool,代码行数:7,代码来源:Extensions.cs

示例3: UInt24

        public UInt24(byte[] bytes, Endianness endianness)
        {
            if (bytes == null) throw new ArgumentNullException("bytes");
            if (bytes.Length != 3) throw new ArgumentException("UInt24 should consist of exactly 3 bytes.", "bytes");

            _bytes = ConvertConditional(bytes, endianness);
        }
开发者ID:JanRou,项目名称:DrNuDownloader,代码行数:7,代码来源:UInt24.cs

示例4: WriteEndian

 public static void WriteEndian(this BinaryWriter BinaryWriter, uint Value, Endianness Endian)
 {
     BinaryWriter.Write((byte)((Value >> 24) & 0xFF));
     BinaryWriter.Write((byte)((Value >> 16) & 0xFF));
     BinaryWriter.Write((byte)((Value >> 8) & 0xFF));
     BinaryWriter.Write((byte)((Value >> 0) & 0xFF));
 }
开发者ID:soywiz,项目名称:csharputils,代码行数:7,代码来源:BinaryReaderWriterExtensions.cs

示例5: EncoderBase

 protected EncoderBase(int bufsize, Endianness endian)
 {
     Endian = endian;
     m_buffersize = bufsize;
     m_buf = new byte[bufsize];
     m_error = false;
 }
开发者ID:GianniBortoloBossini,项目名称:netmq,代码行数:7,代码来源:EncoderBase.cs

示例6: ReadInt32

        public int ReadInt32(Endianness endianness)
        {
            int val = base.ReadInt32();

            if (endianness == Endianness.LittleEndian) { return val; }
            else { return System.Net.IPAddress.NetworkToHostOrder(val); }
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:7,代码来源:BinaryReaderEx.cs

示例7: SaveImage

        public static void SaveImage(this FloatMapImage image, string filename, Endianness endianness)
        {
            FileStream fs = new FileStream(filename, FileMode.Create);

            // write the header
            SaveHeader(fs, image, endianness);

            // write the image data
            for (int y = 0; y < image.Height; y++)
            {
                for (int x = 0; x < image.Width; x++)
                {
                    for (int band = 0; band < image.TotalChannelsCount; band++)
                    {
                        float intensity = image.Image[x, y, band];
                        byte[] rawIntensity = BitConverter.GetBytes(intensity);
                        if (endianness == Endianness.BigEndian)
                        {
                            // swap the bytes from little to big endian
                            SwapFloatEndianness(ref rawIntensity);
                        }
                        // write one float
                        fs.Write(rawIntensity, 0, rawIntensity.Length);
                    }
                }
            }

            fs.Flush();
            fs.Close();
        }
开发者ID:bzamecnik,项目名称:bokehlab,代码行数:30,代码来源:PortableFloatMap.cs

示例8: Unpack

 public void Unpack(Endianness endian, string path)
 {
     if (endian == Endianness.big)
         UnpackBigEndian(path);
     else if(endian == Endianness.little)
         UnpackLittleEndian(path);
 }
开发者ID:chrisall76,项目名称:Sm4sh-Tools,代码行数:7,代码来源:Unpacker.cs

示例9: SpiConnection

        public SpiConnection(ProcessorPin clock, ProcessorPin ss, ProcessorPin? miso, ProcessorPin? mosi, Endianness endianness)
        {
            this.clock = clock;
            this.ss = ss;
            this.miso = miso;
            this.mosi = mosi;
            this.endianness = endianness;

            driver = GpioConnectionSettings.DefaultDriver;

            driver.Allocate(clock, PinDirection.Output);
            driver.Write(clock, false);

            driver.Allocate(ss, PinDirection.Output);
            driver.Write(ss, true);

            if (mosi.HasValue)
            {
                driver.Allocate(mosi.Value, PinDirection.Output);
                driver.Write(mosi.Value, false);
            }

            if (miso.HasValue)
                driver.Allocate(miso.Value, PinDirection.Input);
        }
开发者ID:ranma209,项目名称:raspberry-sharp-io,代码行数:25,代码来源:SpiConnection.cs

示例10: BlenderFileHeaderToken

 public BlenderFileHeaderToken(string identifer, int sz, Endianness endianness, string version)
 {
     Identifier = identifer;
     PointerSize = sz;
     Endianness = endianness;
     Version = version;
 }
开发者ID:jaundice,项目名称:ByteFarm.OpenBionics.Contrib.BlenderInfo,代码行数:7,代码来源:BlenderFileHeaderToken.cs

示例11: ReadSingle

        public float ReadSingle(Endianness endianness)
        {
            if (endianness == Endianness.LittleEndian) { return base.ReadSingle(); }

            byte[] b = base.ReadBytes(4);
            return BitConverter.ToSingle(b.Reverse().ToArray(), 0);
        }
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:7,代码来源:BinaryReaderEx.cs

示例12: PutLong

 /// <summary>
 /// Write the given 64-bit value into the buffer, at the position marked by the offset plus the given index i.
 /// </summary>
 /// <param name="endian">an Endianness to specify in which order to write the bytes</param>
 /// <param name="value">the 64-bit value to write into the byte-array buffer</param>
 /// <param name="i">the index position beyond the offset to start writing the bytes</param>
 public void PutLong(Endianness endian, long value, int i)
 {
     if (endian == Endianness.Big)
     {
         m_innerBuffer[i + Offset] = (byte)(((value) >> 56) & 0xff);
         m_innerBuffer[i + Offset + 1] = (byte)(((value) >> 48) & 0xff);
         m_innerBuffer[i + Offset + 2] = (byte)(((value) >> 40) & 0xff);
         m_innerBuffer[i + Offset + 3] = (byte)(((value) >> 32) & 0xff);
         m_innerBuffer[i + Offset + 4] = (byte)(((value) >> 24) & 0xff);
         m_innerBuffer[i + Offset + 5] = (byte)(((value) >> 16) & 0xff);
         m_innerBuffer[i + Offset + 6] = (byte)(((value) >> 8) & 0xff);
         m_innerBuffer[i + Offset + 7] = (byte)(value & 0xff);
     }
     else
     {
         m_innerBuffer[i + Offset + 7] = (byte)(((value) >> 56) & 0xff);
         m_innerBuffer[i + Offset + 6] = (byte)(((value) >> 48) & 0xff);
         m_innerBuffer[i + Offset + 5] = (byte)(((value) >> 40) & 0xff);
         m_innerBuffer[i + Offset + 4] = (byte)(((value) >> 32) & 0xff);
         m_innerBuffer[i + Offset + 3] = (byte)(((value) >> 24) & 0xff);
         m_innerBuffer[i + Offset + 2] = (byte)(((value) >> 16) & 0xff);
         m_innerBuffer[i + Offset + 1] = (byte)(((value) >> 8) & 0xff);
         m_innerBuffer[i + Offset] = (byte)(value & 0xff);
     }
 }
开发者ID:sharpe5,项目名称:netmq,代码行数:31,代码来源:ByteArraySegment.cs

示例13: EndianReader

        public EndianReader(Stream input, Endianness endianess, Encoding encoding, bool leaveOpen)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }
            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }
            if (!input.CanRead)
                throw new ArgumentException("Can't read from the output stream", nameof(input));
            Contract.EndContractBlock();

            BaseStream = input;
            decoder = encoding.GetDecoder();
            maxCharsSize = encoding.GetMaxCharCount(MaxCharBytesSize);
            var minBufferSize = encoding.GetMaxByteCount(1);  // max bytes per one char
            if (minBufferSize < 16)
                minBufferSize = 16;
            buffer = new byte[minBufferSize];
            // m_charBuffer and m_charBytes will be left null.

            // For Encodings that always use 2 bytes per char (or more), 
            // special case them here to make Read() & Peek() faster.
            use2BytesPerChar = encoding is UnicodeEncoding;
            this.leaveOpen = leaveOpen;

            Endianness = endianess;
            resolvedEndianess = EndianessHelper.Resolve(endianess);

            Contract.Assert(decoder != null, "[EndianReader.ctor]m_decoder!=null");
        }
开发者ID:vbfox,项目名称:U2FExperiments,代码行数:33,代码来源:EndianReader.cs

示例14: RawDecoder

 public RawDecoder(int bufferSize, long maxMsgSize, IMsgSink msgSink,
   Endianness endianness)
     : base(bufferSize, endianness)
 {
     m_msgSink = msgSink;
     m_maxMsgSize = maxMsgSize;
 }
开发者ID:wangkai2014,项目名称:netmq,代码行数:7,代码来源:RawDecoder.cs

示例15: ReadFloat

        //THIS IS UNFINISHED BECAUSE I CAN'T TEST IT. TRY IT LATER
        public static float ReadFloat(byte[] data, int position, Endianness endian = Endianness.BigEndian)
        {
            if (data == null || data.Length < position + 4)
                throw new Exception();

            byte[] bytes = new byte[4];
            Array.Copy(data, position, bytes, 0, 4);
            bytes = bytes.Reverse().ToArray();
            return BitConverter.ToSingle(bytes, 0);

            switch (endian)
            {
                case Endianness.BigEndian:
                    //Do nothing
                    break;
                case Endianness.LittleEndian:
                    //Reverse
                    break;
                case Endianness.ByteSwap:

                    break;
                case Endianness.WordSwap:

                    break;
            }

            return 0;
        }
开发者ID:mib-f8sm9c,项目名称:NewSF64Toolkit,代码行数:29,代码来源:ByteHelper.cs


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