From 8c7773e6cdf27f83bc9aaec4e35be78fc5935579 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 11 Aug 2019 01:52:00 +0200 Subject: [PATCH] Removed image classes --- src/DirectX12GameEngine.Graphics/Image.cs | 61 ------------------- .../ImageDescription.cs | 31 ---------- 2 files changed, 92 deletions(-) delete mode 100644 src/DirectX12GameEngine.Graphics/Image.cs delete mode 100644 src/DirectX12GameEngine.Graphics/ImageDescription.cs diff --git a/src/DirectX12GameEngine.Graphics/Image.cs b/src/DirectX12GameEngine.Graphics/Image.cs deleted file mode 100644 index f598faa8..00000000 --- a/src/DirectX12GameEngine.Graphics/Image.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.IO; -using System.Threading.Tasks; -using SharpDX.DXGI; -using Windows.Graphics.Imaging; - -namespace DirectX12GameEngine.Graphics -{ - public sealed class Image : IDisposable - { - public Memory Data { get; } - - public ImageDescription Description { get; } - - public int Width => Description.Width; - - public int Height => Description.Height; - - internal Image() - { - } - - internal Image(ImageDescription description, Memory data) - { - Description = description; - Data = data; - } - - public static async Task LoadAsync(string filePath) - { - using FileStream stream = File.OpenRead(filePath); - return await LoadAsync(stream); - } - - public static async Task LoadAsync(Stream stream) - { - BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream.AsRandomAccessStream()); - - PixelDataProvider pixelDataProvider = await decoder.GetPixelDataAsync( - decoder.BitmapPixelFormat, decoder.BitmapAlphaMode, new BitmapTransform(), - ExifOrientationMode.RespectExifOrientation, ColorManagementMode.DoNotColorManage); - - byte[] imageBuffer = pixelDataProvider.DetachPixelData(); - - PixelFormat pixelFormat = decoder.BitmapPixelFormat switch - { - BitmapPixelFormat.Rgba8 => PixelFormat.R8G8B8A8_UNorm, - BitmapPixelFormat.Bgra8 => PixelFormat.B8G8R8A8_UNorm, - _ => throw new NotSupportedException("This format is not supported.") - }; - - ImageDescription description = ImageDescription.New2D((int)decoder.PixelWidth, (int)decoder.OrientedPixelHeight, pixelFormat); - - return new Image(description, imageBuffer); - } - - public void Dispose() - { - } - } -} diff --git a/src/DirectX12GameEngine.Graphics/ImageDescription.cs b/src/DirectX12GameEngine.Graphics/ImageDescription.cs deleted file mode 100644 index cf605e31..00000000 --- a/src/DirectX12GameEngine.Graphics/ImageDescription.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace DirectX12GameEngine.Graphics -{ - public struct ImageDescription - { - - public int Width; - - public int Height; - - public int Depth; - - public int ArraySize; - - public int MipLevels; - - public PixelFormat Format; - - public static ImageDescription New2D(int width, int height, PixelFormat format, int mipCount = 1, int arraySize = 1) - { - return new ImageDescription - { - Width = width, - Height = height, - Depth = 1, - ArraySize = arraySize, - Format = format, - MipLevels = mipCount, - }; - } - } -}