I'm using this code to load TGA-images: https://www.codeproject.com/Articles/31702/NET-Targa-Image-Reader
It's released under CPOL-license, so should be comparable to MIT-license and won't bring problems, when using it
using Paloma;
...
var image = new TargaImage(filename);
var format = Format.Unknown;
var imageData = image.Image;
if(image.Header.PixelDepth==24) {
format = Format.B8G8R8A8_UNorm;
imageData = image.Image.Clone(new System.Drawing.Rectangle(0, 0, image.Image.Width, image.Image.Height), System.Drawing.Imaging.PixelFormat.Format32bppRgb);
}
var bitmapData = imageData.LockBits(new System.Drawing.Rectangle(0, 0, image.Image.Width, image.Image.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, imageData.PixelFormat);
var bufferSize = bitmapData.Height * bitmapData.Stride;
// copy our buffer to the texture
int stride = image.Image.Width * 4;
var tex = new Texture2D(device, new Texture2DDescription() {
Width = image.Header.Width,
Height = image.Header.Height,
Format = format,
ArraySize = 1,
BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget,
Usage = ResourceUsage.Default,
CpuAccessFlags = CpuAccessFlags.None,
MipLevels = GetNumMipLevels(image.Header.Width,image.Header.Height),
OptionFlags = ResourceOptionFlags.GenerateMipMaps,
SampleDescription = new SampleDescription(1, 0),
});
device.ImmediateContext.UpdateSubresource(tex,0,null,bitmapData.Scan0,stride,0);
// unlock the bitmap data
imageData.UnlockBits(bitmapData);