private static uint GetVtfHighResFormatValue(DxtImageFormat imageFormat) { // If we use FormatDxt1OneBitAlpha, game engines will not interperate the image correctly. // Just use Dxt1 without the alpha flag. return(imageFormat switch { DxtImageFormat.Dxt5 => VtfConstants.FormatDxt5, DxtImageFormat.Dxt1OneBitAlpha => VtfConstants.FormatDxt1, _ => throw new NotImplementedException($"No case added for {nameof(DxtImageFormat)}.{imageFormat}."), });
private static void EnsureStreamCapacityIfPossible(Stream stream, DxtImageFormat imageFormat, ICollection <Image <Rgba32> > images) { var neededBytes = (int)VtfConstants.HeaderSize + CalculateSizeInBytes(imageFormat, images); if (stream is MemoryStream memStream) { memStream.Capacity = neededBytes; } else if (stream is FileStream fileStream) { fileStream.SetLength(neededBytes); } }