Removed image classes
このコミットが含まれているのは:
1 親
198e01ce50
コミット
8c7773e6cd
2ファイル変更
-92
検索条件に一致するファイルはありません
@@ -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<byte> Data { get; }
|
||||
|
||||
public ImageDescription Description { get; }
|
||||
|
||||
public int Width => Description.Width;
|
||||
|
||||
public int Height => Description.Height;
|
||||
|
||||
internal Image()
|
||||
{
|
||||
}
|
||||
|
||||
internal Image(ImageDescription description, Memory<byte> data)
|
||||
{
|
||||
Description = description;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public static async Task<Image> LoadAsync(string filePath)
|
||||
{
|
||||
using FileStream stream = File.OpenRead(filePath);
|
||||
return await LoadAsync(stream);
|
||||
}
|
||||
|
||||
public static async Task<Image> 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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする