コード例 #1
0
        // TODO: It would be nice to have this method in PixelOperations<T>
        private static void ToArgb32 <TPixel>(Span <TPixel> source, Span <Argb32> dest)
            where TPixel : struct, IPixel <TPixel>
        {
            int length = source.Length;

            Guard.MustBeSizedAtLeast(dest, length, nameof(dest));

            using (var rgbaBuffer = new Buffer <Rgba32>(length))
            {
                PixelOperations <TPixel> .Instance.ToRgba32(source, rgbaBuffer, length);

                for (int i = 0; i < length; i++)
                {
                    ref Rgba32 s = ref rgbaBuffer[i];
                    ref Argb32 d = ref dest[i];

                    d.PackFromRgba32(s);
                }
コード例 #2
0
        // TODO: It would be nice to have this method in PixelOperations<T>
        private static void ToArgb32 <TPixel>(Span <TPixel> source, Span <Argb32> dest)
            where TPixel : struct, IPixel <TPixel>
        {
            int length = source.Length;

            Guard.MustBeSizedAtLeast(dest, length, nameof(dest));

            using (IBuffer <Rgba32> rgbaBuffer = Configuration.Default.MemoryManager.Allocate <Rgba32>(length))
            {
                Span <Rgba32> rgbaSpan = rgbaBuffer.Span;
                PixelOperations <TPixel> .Instance.ToRgba32(source, rgbaSpan, length);

                for (int i = 0; i < length; i++)
                {
                    ref Rgba32 s = ref rgbaSpan[i];
                    ref Argb32 d = ref dest[i];

                    d.PackFromRgba32(s);
                }