예제 #1
0
        /// <summary>
        /// Creates a clean instance of <see cref="PinnedImageBuffer{T}"/> initializing it's elements with 'default(T)'.
        /// </summary>
        /// <param name="width">The number of elements in a row</param>
        /// <param name="height">The number of rows</param>
        /// <returns>The <see cref="PinnedBuffer{T}"/> instance</returns>
        public static PinnedImageBuffer <T> CreateClean(int width, int height)
        {
            PinnedImageBuffer <T> buffer = new PinnedImageBuffer <T>(width, height);

            buffer.Clear();
            return(buffer);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PixelAccessor{TColor}" /> class.
        /// </summary>
        /// <param name="width">The width of the image represented by the pixel buffer.</param>
        /// <param name="height">The height of the image represented by the pixel buffer.</param>
        /// <param name="pixels">The pixel buffer.</param>
        private PixelAccessor(int width, int height, PinnedImageBuffer <TColor> pixels)
        {
            Guard.NotNull(pixels, nameof(pixels));
            Guard.MustBeGreaterThan(width, 0, nameof(width));
            Guard.MustBeGreaterThan(height, 0, nameof(height));

            this.SetPixelBufferUnsafe(width, height, pixels);

            this.ParallelOptions = Configuration.Default.ParallelOptions;
        }
예제 #3
0
        /// <summary>
        /// Sets the pixel buffer in an unsafe manor this should not be used unless you know what its doing!!!
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="pixels">The pixel buffer</param>
        private void SetPixelBufferUnsafe(int width, int height, PinnedImageBuffer <TColor> pixels)
        {
            this.pixelBuffer = pixels;
            this.pixelsBase  = (byte *)pixels.Pointer;

            this.Width     = width;
            this.Height    = height;
            this.PixelSize = Unsafe.SizeOf <TColor>();
            this.RowStride = this.Width * this.PixelSize;
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PixelAccessor{TColor}"/> class.
 /// </summary>
 /// <param name="width">The width of the image represented by the pixel buffer.</param>
 /// <param name="height">The height of the image represented by the pixel buffer.</param>
 public PixelAccessor(int width, int height)
     : this(width, height, PinnedImageBuffer <TColor> .CreateClean(width, height))
 {
 }