public static byte[] ConvertDDS(GUIDEntry value, DXGI_FORMAT targetFormat, DDSConverter.ImageFormat imageFormat, int frame) { try { if (GetDataType(value) != DataType.Image) { return(null); } teTexture texture = new teTexture(IOHelper.OpenFile(value)); if (texture.PayloadRequired) { ulong payload = texture.GetPayloadGUID(value.GUID, 1); if (IOHelper.HasFile(payload)) { texture.LoadPayload(IOHelper.OpenFile(payload), 1); } else { return(null); } } Stream ms = texture.SaveToDDS(1); return(DDSConverter.ConvertDDS(ms, targetFormat, imageFormat, frame)); } catch { // ignored } return(null); }
internal static teTexture LoadTexture(GUIDEntry value, Stream fileStream = null) { teTexture texture = new teTexture(fileStream ?? IOHelper.OpenFile(value)); if (texture.PayloadRequired) { ulong payload = texture.GetPayloadGUID(value.GUID, 0); if (IOHelper.HasFile(payload)) { texture.LoadPayload(IOHelper.OpenFile(payload), 0); } else { return(null); } } return(texture); }