ImageMagick.ByteConverter.ToInt C# (CSharp) Method

ToInt() public static method

public static ToInt ( byte data, int &offset ) : int
data byte
offset int
return int
    public static int ToInt(byte[] data, ref int offset)
    {
      if (offset + 4 > data.Length)
        return 0;

      int test = (int)BitConverter.ToUInt32(data, offset);
      if (test == -1)
        return 0;

      int result = data[offset++] << 24;
      result = result | (data[offset++] << 16);
      result = result | (data[offset++] << 8);
      result = result | data[offset++];
      return (int)(result & 0xffffffff);
    }

Usage Example

Example #1
0
        private PointD[] CreatePoint(Byte[] data)
        {
            PointD[] result = new PointD[3];

            for (int i = 0; i < 3; i++)
            {
                uint yy = (uint)ByteConverter.ToInt(data, ref _Index);
                int  y  = (int)yy;
                if (yy > 2147483647)
                {
                    y = (int)(yy - 4294967295U - 1);
                }

                uint xx = (uint)ByteConverter.ToInt(data, ref _Index);
                int  x  = (int)xx;
                if (xx > 2147483647)
                {
                    x = (int)(xx - 4294967295U - 1);
                }

                result[i] = new PointD((double)x * _Width / 4096 / 4096, (double)y * _Height / 4096 / 4096);
            }

            return(result);
        }
All Usage Examples Of ImageMagick.ByteConverter::ToInt