Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: prevent image loading crash when actual channel is not three #87

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ResourceLayer/File/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ Image::Image(const std::string &path, ImageLoadMode ilm) {
isHdr = stbi_is_hdr(path.c_str());
int w, h, c;
if (isHdr) {
float *data = stbi_loadf(path.c_str(), &w, &h, &c, 3);
float *data = stbi_loadf(path.c_str(), &w, &h, &c, 0);
imageRawData = new float[w * h * c];
std::memcpy(imageRawData, data, w * h * c * sizeof(float));
free(data);
} else
// todo: bw mode
{
unsigned char *data = stbi_load(path.c_str(), &w, &h, &c, 3);
unsigned char *data = stbi_load(path.c_str(), &w, &h, &c, 0);
if (!data) {
std::cout << "Fail to load image " << path << std::endl;
return;
Expand Down
Loading