Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
40 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <filesystem> | ||
|
||
#include "image.hpp" | ||
|
||
#include <stb_image_write.h> | ||
|
||
void write_image_file(std::string filename, Resolution res, const void* data) | ||
{ | ||
auto [width, height] = res; | ||
|
||
std::filesystem::path output_path{filename}; | ||
|
||
if (output_path.extension() == ".png") { | ||
if (stbi_write_png(filename.c_str(), width, height, 4, data, 0) == 0) { | ||
SPDLOG_CRITICAL("Failed to write to image file {}", filename); | ||
} | ||
} else { | ||
fmt::print(stderr, "{} has an unrecognized extension\n", filename); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef CUDA_PATH_TRACER_IMAGE_HPP | ||
#define CUDA_PATH_TRACER_IMAGE_HPP | ||
|
||
#include <string> | ||
|
||
#include "resolution.hpp" | ||
|
||
void write_image_file(std::string filename, Resolution res, const void* data); | ||
|
||
#endif // CUDA_PATH_TRACER_IMAGE_HPP |