Generate mipmaps for textures
This commit is contained in:
parent
15c69f3092
commit
f85514a40a
|
@ -7,12 +7,12 @@ public partial class TextureLoader
|
||||||
{
|
{
|
||||||
// References:
|
// References:
|
||||||
// - https://www.w3.org/Graphics/GIF/spec-gif89a.txt
|
// - https://www.w3.org/Graphics/GIF/spec-gif89a.txt
|
||||||
private static ImageTexture LoadGif(string path)
|
private static Image LoadGif(string path)
|
||||||
{
|
{
|
||||||
var gif = new GifDecoder(path);
|
var gif = new GifDecoder(path);
|
||||||
var gifImage = gif.GetImage(0);
|
var gifImage = gif.GetImage(0);
|
||||||
var bytes = gifImage.GetRgbaBytes();
|
var bytes = gifImage.GetRgbaBytes();
|
||||||
var image = Image.CreateFromData(gifImage.Width, gifImage.Height, false, Image.Format.Rgba8, bytes);
|
var image = Image.CreateFromData(gifImage.Width, gifImage.Height, false, Image.Format.Rgba8, bytes);
|
||||||
return ImageTexture.CreateFromImage(image);
|
return image;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@ public partial class TextureLoader
|
||||||
// References:
|
// References:
|
||||||
// - https://www.fileformat.info/format/pcx/egff.htm
|
// - https://www.fileformat.info/format/pcx/egff.htm
|
||||||
// - http://www.fysnet.net/pcxfile.htm
|
// - http://www.fysnet.net/pcxfile.htm
|
||||||
private static ImageTexture LoadPcx(string path)
|
private static Image LoadPcx(string path)
|
||||||
{
|
{
|
||||||
static Color[] LoadFamilyPalette(string famPath)
|
static Color[] LoadFamilyPalette(string famPath)
|
||||||
{
|
{
|
||||||
|
@ -119,6 +119,6 @@ public partial class TextureLoader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ImageTexture.CreateFromImage(image);
|
return image;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,13 +60,14 @@ public partial class TextureLoader
|
||||||
string[] validExtensions = { "png", "tga", "pcx", "gif" };
|
string[] validExtensions = { "png", "tga", "pcx", "gif" };
|
||||||
if (validExtensions.Contains(ext))
|
if (validExtensions.Contains(ext))
|
||||||
{
|
{
|
||||||
var texture = ext switch
|
var image = ext switch
|
||||||
{
|
{
|
||||||
"pcx" => LoadPcx(path),
|
"pcx" => LoadPcx(path),
|
||||||
"gif" => LoadGif(path),
|
"gif" => LoadGif(path),
|
||||||
_ => ImageTexture.CreateFromImage(Image.LoadFromFile(path)),
|
_ => Image.LoadFromFile(path),
|
||||||
};
|
};
|
||||||
return texture;
|
image.GenerateMipmaps();
|
||||||
|
return ImageTexture.CreateFromImage(image);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue