public void TEST_WriteDDSToDisk(string destinationPath) { //THIS WORKS string extension = Path.GetExtension(destinationPath); string newPath = destinationPath.Remove(destinationPath.Length - extension.Length, extension.Length); newPath += "_parseTest" + extension; byte[] finalData = new byte[0]; //turn our header data into bytes to be written into a file byte[] dds_header = ByteFunctions.Combine(ByteFunctions.GetBytes("DDS "), DDS_Functions.GetHeaderBytes(header)); //copy the dds header to the file finalData = ByteFunctions.Combine(finalData, dds_header); //copy the images for (int i = 0; i <= textureData.Count - 1; i++) { finalData = ByteFunctions.Combine(finalData, textureData[i]); } //write the file to the disk File.WriteAllBytes(newPath, finalData); }
/// <summary> /// Writes a D3DTX into a DDS file on the disk. /// </summary> /// <param name="d3dtx"></param> /// <param name="destinationPath"></param> public void Write_D3DTX_AsDDS(D3DTX_Master d3dtx, string destinationPath) { byte[] finalData = new byte[0]; //turn our header data into bytes to be written into a file byte[] dds_header = ByteFunctions.Combine(ByteFunctions.GetBytes("DDS "), DDS_Functions.GetHeaderBytes(header)); //copy the dds header to the file finalData = ByteFunctions.Combine(finalData, dds_header); if (d3dtx.d3dtx4 != null) { //copy the images for (int i = d3dtx.d3dtx4.mPixelData.Count - 1; i >= 0; i--) { finalData = ByteFunctions.Combine(finalData, d3dtx.d3dtx4.mPixelData[i]); } } else if (d3dtx.d3dtx5 != null) { //copy the images for (int i = d3dtx.d3dtx5.mPixelData.Count - 1; i >= 0; i--) { finalData = ByteFunctions.Combine(finalData, d3dtx.d3dtx5.mPixelData[i]); } } else if (d3dtx.d3dtx6 != null) { //copy the images for (int i = d3dtx.d3dtx6.mPixelData.Count - 1; i >= 0; i--) { finalData = ByteFunctions.Combine(finalData, d3dtx.d3dtx6.mPixelData[i]); } } else if (d3dtx.d3dtx7 != null) { //copy the images for (int i = d3dtx.d3dtx7.mPixelData.Count - 1; i >= 0; i--) { finalData = ByteFunctions.Combine(finalData, d3dtx.d3dtx7.mPixelData[i]); } } else if (d3dtx.d3dtx8 != null) { //copy the images for (int i = d3dtx.d3dtx8.mPixelData.Count - 1; i >= 0; i--) { finalData = ByteFunctions.Combine(finalData, d3dtx.d3dtx8.mPixelData[i]); } } else if (d3dtx.d3dtx9 != null) { //copy the images for (int i = d3dtx.d3dtx9.mPixelData.Count - 1; i >= 0; i--) { finalData = ByteFunctions.Combine(finalData, d3dtx.d3dtx9.mPixelData[i]); } } //write the file to the disk File.WriteAllBytes(destinationPath, finalData); }