Axiom.Media.PixelUtil.GetNumElemBytes C# (CSharp) Метод

GetNumElemBytes() публичный статический Метод

Returns the size in bytes of an element of the given pixel format.
public static GetNumElemBytes ( PixelFormat format ) : int
format PixelFormat Pixel format to test.
Результат int
		public static int GetNumElemBytes( PixelFormat format )
		{
			return PixelConverter.GetDescriptionFor( format ).elemBytes;
		}

Usage Example

Пример #1
0
        /// <summary>
        ///   Return a subvolume of this PixelBox.
        /// </summary>
        /// <param name="def"> Defines the bounds of the subregion to return </param>
        /// <returns> A pixel box describing the region and the data in it </returns>
        /// <remarks>
        ///   This function does not copy any data, it just returns a PixelBox object with a data pointer pointing somewhere inside the data of object. Throws an Exception if def is not fully contained.
        /// </remarks>
        public PixelBox GetSubVolume(BasicBox def)
        {
            if (Compressed(this.format))
            {
                if (def.Left == left && def.Top == top && def.Front == front && def.Right == right && def.Bottom == bottom &&
                    def.Back == back)
                {
                    // Entire buffer is being queried
                    return(this);
                }
                throw new Exception("Cannot return subvolume of compressed PixelBuffer, in PixelBox.GetSubVolume");
            }
            if (!Contains(def))
            {
                throw new Exception("Bounds out of range, in PixelBox.GetSubVolume");
            }

            var elemSize = PixelUtil.GetNumElemBytes(this.format);
            // Calculate new data origin
            var rval = new PixelBox(def, this.format, this.data);

            rval.offset = (((def.Left - left) * elemSize) + ((def.Top - top) * this.rowPitch * elemSize) +
                           ((def.Front - front) * this.slicePitch * elemSize));
            rval.rowPitch   = this.rowPitch;
            rval.slicePitch = this.slicePitch;
            rval.format     = this.format;
            return(rval);
        }
All Usage Examples Of Axiom.Media.PixelUtil::GetNumElemBytes