コード例 #1
0
        public void Encode <TPixel>(Image <TPixel> image, Stream stream) where TPixel : unmanaged, IPixel <TPixel>
        {
            if (_imageType != VtfImageType.Single1024 &&
                _imageType != VtfImageType.Single512)
            {
                throw new Exception($"Use {nameof(EncodeWithMipmapsAsync)}() directly for images that require mipmaps.");
            }

            var encoder = new VtfEncoderCore(_imageType);

            if (!(image is Image <Rgba32> imageAsRgba32))
            {
                imageAsRgba32 = image.CloneAs <Rgba32>();
            }
            encoder.Encode(imageAsRgba32, stream, default);
        }
コード例 #2
0
        public async Task EncodeAsync <TPixel>(Image <TPixel> image, Stream stream, CancellationToken cancellationToken)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            if (_imageType != VtfImageType.Single1024 &&
                _imageType != VtfImageType.Single512)
            {
                throw new Exception($"Use {nameof(EncodeWithMipmapsAsync)}() directly for images that require mipmaps.");
            }

            var encoder = new VtfEncoderCore(_imageType);

            if (!(image is Image <Rgba32> imageAsRgba32))
            {
                imageAsRgba32 = image.CloneAs <Rgba32>();
            }
            await encoder.EncodeAsync(imageAsRgba32, stream, cancellationToken).ConfigureAwait(false);
        }
コード例 #3
0
        public Task EncodeWithMipmapsAsync(IList <Image <Rgba32> > images, Stream stream, CancellationToken cancellationToken)
        {
            var encoder = new VtfEncoderCore(_imageType);

            return(encoder.EncodeAsync(images, stream, cancellationToken));
        }