|
|
|
@ -2,6 +2,7 @@ |
|
|
|
#include <cassert> |
|
|
|
#include <cassert> |
|
|
|
#include <cstdlib> |
|
|
|
#include <cstdlib> |
|
|
|
#include <cstdio> |
|
|
|
#include <cstdio> |
|
|
|
|
|
|
|
#include <cstring> |
|
|
|
|
|
|
|
|
|
|
|
#define STB_IMAGE_IMPLEMENTATION |
|
|
|
#define STB_IMAGE_IMPLEMENTATION |
|
|
|
#include "stb_image.h" |
|
|
|
#include "stb_image.h" |
|
|
|
@ -66,8 +67,10 @@ util_image |
|
|
|
utilLoadImage(const char* filename) |
|
|
|
utilLoadImage(const char* filename) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOG(INFO) << "Loading Image: " << filename << "\n"; |
|
|
|
LOG(INFO) << "Loading Image: " << filename << "\n"; |
|
|
|
|
|
|
|
assert(std::strlen(filename) < 256); |
|
|
|
|
|
|
|
|
|
|
|
util_image image; |
|
|
|
util_image image; |
|
|
|
|
|
|
|
std::memcpy(image.file_path, filename, std::strlen(filename) + 1); |
|
|
|
image.pixels = stbi_load(filename, &image.w, &image.h, &image.num_channels, 0); |
|
|
|
image.pixels = stbi_load(filename, &image.w, &image.h, &image.num_channels, 0); |
|
|
|
image.data_len = image.w * image.h * image.num_channels; // NOTE: assumes 8 bits per channel
|
|
|
|
image.data_len = image.w * image.h * image.num_channels; // NOTE: assumes 8 bits per channel
|
|
|
|
|
|
|
|
|
|
|
|
@ -89,5 +92,6 @@ utilFreeImage(util_image image) |
|
|
|
image.w = image.h = image.data_len = 0; |
|
|
|
image.w = image.h = image.data_len = 0; |
|
|
|
image.bits_per_channel = 8; |
|
|
|
image.bits_per_channel = 8; |
|
|
|
image.num_channels = 4; |
|
|
|
image.num_channels = 4; |
|
|
|
|
|
|
|
std::memset(image.file_path, 0, std::strlen(image.file_path) + 1); |
|
|
|
utilSafeFree(image.pixels); |
|
|
|
utilSafeFree(image.pixels); |
|
|
|
} |
|
|
|
} |
|
|
|
|