示例#1
0
        /// <summary>
        /// Gets the pixel at the specified position.
        /// </summary>
        /// <param name="x">The x position.</param>
        /// <param name="y">The y position.</param>
        /// <param name="z">The z position.</param>
        /// <param name="wrapMode">The wrap mode.</param>
        /// <returns>The pixel color.</returns>
        public Vector4F GetPixel(int x, int y, int z, TextureAddressMode wrapMode)
        {
            switch (wrapMode)
            {
            case TextureAddressMode.Clamp:
                x = TextureHelper.WrapClamp(x, _width);
                y = TextureHelper.WrapClamp(y, _height);
                z = TextureHelper.WrapClamp(z, _depth);
                break;

            case TextureAddressMode.Repeat:
                x = TextureHelper.WrapRepeat(x, _width);
                y = TextureHelper.WrapRepeat(y, _height);
                z = TextureHelper.WrapRepeat(z, _depth);
                break;

            case TextureAddressMode.Mirror:
                x = TextureHelper.WrapMirror(x, _width);
                y = TextureHelper.WrapMirror(y, _height);
                z = TextureHelper.WrapMirror(z, _depth);
                break;
            }

            unsafe
            {
                float *ptr = (float *)_intPtrs[z].ToPointer() + (y * _width + x) * 4;
                return(new Vector4F(*ptr++, *ptr++, *ptr++, *ptr));
            }
        }
示例#2
0
        /// <summary>
        /// Gets the pixel at the specified position.
        /// </summary>
        /// <param name="x">The x position.</param>
        /// <param name="y">The y position.</param>
        /// <param name="wrapMode">The wrap mode.</param>
        /// <returns>The pixel color.</returns>
        public Vector4F GetPixel(int x, int y, TextureAddressMode wrapMode)
        {
            switch (wrapMode)
            {
            case TextureAddressMode.Clamp:
                x = TextureHelper.WrapClamp(x, _width);
                y = TextureHelper.WrapClamp(y, _height);
                break;

            case TextureAddressMode.Repeat:
                x = TextureHelper.WrapRepeat(x, _width);
                y = TextureHelper.WrapRepeat(y, _height);
                break;

            case TextureAddressMode.Mirror:
                x = TextureHelper.WrapMirror(x, _width);
                y = TextureHelper.WrapMirror(y, _height);
                break;
            }

            return(GetPixel(y * _width + x));
        }