添加输出图片为png格式的支持
							parent
							
								
									aff5dee7d4
								
							
						
					
					
						commit
						6e34140783
					
				| 
						 | 
					@ -9,6 +9,7 @@ include_directories(external)
 | 
				
			||||||
include_directories(external/glm)
 | 
					include_directories(external/glm)
 | 
				
			||||||
include_directories(external/gli)
 | 
					include_directories(external/gli)
 | 
				
			||||||
include_directories(external/imgui)
 | 
					include_directories(external/imgui)
 | 
				
			||||||
 | 
					include_directories(external/stb)
 | 
				
			||||||
include_directories(external/tinygltf)
 | 
					include_directories(external/tinygltf)
 | 
				
			||||||
include_directories(external/ktx/include)
 | 
					include_directories(external/ktx/include)
 | 
				
			||||||
include_directories(external/ktx/other_include)
 | 
					include_directories(external/ktx/other_include)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -119,7 +119,7 @@ public:
 | 
				
			||||||
		bool multiSampling = true; // 多重采样
 | 
							bool multiSampling = true; // 多重采样
 | 
				
			||||||
		bool rotateModel = true; // 模型自旋转(暂时失效)
 | 
							bool rotateModel = true; // 模型自旋转(暂时失效)
 | 
				
			||||||
		bool headless = false; // 无头开关
 | 
							bool headless = false; // 无头开关
 | 
				
			||||||
 | 
							bool outputPNGimage = true;
 | 
				
			||||||
		bool enableSaveToImageSequeue = false; // 图片序列开关(暂时弃用)
 | 
							bool enableSaveToImageSequeue = false; // 图片序列开关(暂时弃用)
 | 
				
			||||||
		uint32_t outputFrameCount = 75; // 图片序列结束帧
 | 
							uint32_t outputFrameCount = 75; // 图片序列结束帧
 | 
				
			||||||
		bool takeScreenShot = false; // 截屏(暂时弃用)
 | 
							bool takeScreenShot = false; // 截屏(暂时弃用)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -1755,6 +1755,14 @@ PlumageRender::PlumageRender()
 | 
				
			||||||
		vkMapMemory(device, dstImageMemory, 0, VK_WHOLE_SIZE, 0, (void**)&data);
 | 
							vkMapMemory(device, dstImageMemory, 0, VK_WHOLE_SIZE, 0, (void**)&data);
 | 
				
			||||||
		data += subResourceLayout.offset;
 | 
							data += subResourceLayout.offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (settings.outputPNGimage)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								stbi_write_png(filePath.c_str(), width, height, 4, data, static_cast<int>(subResourceLayout.rowPitch));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			std::ofstream file(filePath, std::ios::out | std::ios::binary);
 | 
								std::ofstream file(filePath, std::ios::out | std::ios::binary);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// ppm header
 | 
								// ppm header
 | 
				
			||||||
| 
						 | 
					@ -1770,6 +1778,8 @@ PlumageRender::PlumageRender()
 | 
				
			||||||
				colorSwizzle = (std::find(formatsBGR.begin(), formatsBGR.end(), swapChain.colorFormat) != formatsBGR.end());
 | 
									colorSwizzle = (std::find(formatsBGR.begin(), formatsBGR.end(), swapChain.colorFormat) != formatsBGR.end());
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							
 | 
				
			||||||
			// ppm binary pixel data
 | 
								// ppm binary pixel data
 | 
				
			||||||
			for (uint32_t y = 0; y < height; y++)
 | 
								for (uint32_t y = 0; y < height; y++)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -1791,6 +1801,9 @@ PlumageRender::PlumageRender()
 | 
				
			||||||
				data += subResourceLayout.rowPitch;
 | 
									data += subResourceLayout.rowPitch;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			file.close();
 | 
								file.close();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::cout << "Screenshot saved to " << filePath << std::endl;
 | 
							std::cout << "Screenshot saved to " << filePath << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1821,7 +1834,18 @@ PlumageRender::PlumageRender()
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			signal.imageSequenceOutputComplete = true;
 | 
								signal.imageSequenceOutputComplete = true;
 | 
				
			||||||
			std::string fileName = "/%dresult.ppm";
 | 
					
 | 
				
			||||||
 | 
								std::string fileName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (settings.outputPNGimage)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									fileName = "/%dresult.png";
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									fileName = "/%dresult.ppm";
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
			filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName;
 | 
								filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName;
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -1829,7 +1853,16 @@ PlumageRender::PlumageRender()
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			std::filesystem::create_directories(filePath.deviceSpecFilePath.c_str());
 | 
								std::filesystem::create_directories(filePath.deviceSpecFilePath.c_str());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		std::string fileName ="/" + std::to_string(savedFrameCounter) + "result.ppm";
 | 
							std::string fileNameSuffix;
 | 
				
			||||||
 | 
							if (settings.outputPNGimage)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								fileNameSuffix = "result.png";
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								fileNameSuffix = "dresult.ppm";
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							std::string fileName ="/" + std::to_string(savedFrameCounter) + fileNameSuffix;
 | 
				
			||||||
		filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName;
 | 
							filePath.totalImageOutputPath = filePath.deviceSpecFilePath + fileName;
 | 
				
			||||||
		//std::cout << outputPath << std::endl;
 | 
							//std::cout << outputPath << std::endl;
 | 
				
			||||||
		writeImageToFile(filePath.totalImageOutputPath.c_str());
 | 
							writeImageToFile(filePath.totalImageOutputPath.c_str());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,9 @@
 | 
				
			||||||
#include<dirent.h>
 | 
					#include<dirent.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define STB_IMAGE_WRITE_IMPLEMENTATION
 | 
				
			||||||
 | 
					#include "stb/stb_image_write.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue