public void ConsumedBuffer_IsMemoryOwner_ReturnsFalse()
            {
                var memory = new Memory <int>(new int[55]);
                var buffer = new ConsumedBuffer <int>(memory);

                Assert.False(buffer.IsMemoryOwner);
            }
Beispiel #2
0
        // TODO: This is a WIP API, should be public when finished.

        /// <summary>
        /// Wraps an existing contigous memory area of 'width'x'height' pixels,
        /// allowing to view/manipulate it as an ImageSharp <see cref="Image{TPixel}"/> instance.
        /// </summary>
        /// <typeparam name="TPixel">The pixel type</typeparam>
        /// <param name="config">The <see cref="Configuration"/></param>
        /// <param name="pixelMemory">The pixel memory</param>
        /// <param name="width">The width of the memory image</param>
        /// <param name="height">The height of the memory image</param>
        /// <param name="metaData">The <see cref="ImageMetaData"/></param>
        /// <returns>An <see cref="Image{TPixel}"/> instance</returns>
        internal static Image <TPixel> WrapMemory <TPixel>(
            Configuration config,
            Memory <TPixel> pixelMemory,
            int width,
            int height,
            ImageMetaData metaData)
            where TPixel : struct, IPixel <TPixel>
        {
            var buffer = new ConsumedBuffer <TPixel>(pixelMemory);

            return(new Image <TPixel>(config, buffer, width, height, metaData));
        }