|
@@ -1,48 +1,47 @@
|
|
|
+#define IMPORT_CORE
|
|
|
#include "core/Image.h"
|
|
|
|
|
|
#include <core/Utility.h>
|
|
|
#define STB_IMAGE_IMPLEMENTATION
|
|
|
#define STBI_ONLY_PNG
|
|
|
-#define STBI_MALLOC(n) coreAllocate(n)
|
|
|
-#define STBI_REALLOC(p, n) coreReallocate(p, n)
|
|
|
-#define STBI_FREE(p) coreFree(p)
|
|
|
+#define STBI_MALLOC(n) cAllocate(n)
|
|
|
+#define STBI_REALLOC(p, n) cReallocate(p, n)
|
|
|
+#define STBI_FREE(p) cFree(p)
|
|
|
#include <core/Logger.h>
|
|
|
#include <errno.h>
|
|
|
#include <stb_image.h>
|
|
|
#include <string.h>
|
|
|
|
|
|
static void printError(const char* path) {
|
|
|
- CORE_LOG_ERROR("Cannot read image '%s': %s", path, strerror(errno));
|
|
|
+ LOG_ERROR("Cannot read image '%s': %s", path, strerror(errno));
|
|
|
}
|
|
|
|
|
|
-bool coreInitImage8(CoreImage8* image, const char* path) {
|
|
|
- *image = (CoreImage8){0};
|
|
|
- image->data =
|
|
|
- stbi_load(path, &image->width, &image->height, &image->channels, 0);
|
|
|
- if(image->data == nullptr) {
|
|
|
+bool initImage8(Image8* i, const char* path) {
|
|
|
+ *i = (Image8){0};
|
|
|
+ i->data = stbi_load(path, &i->width, &i->height, &i->channels, 0);
|
|
|
+ if(i->data == nullptr) {
|
|
|
printError(path);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-void coreDestroyImage8(CoreImage8* image) {
|
|
|
- stbi_image_free(image->data);
|
|
|
- *image = (CoreImage8){0};
|
|
|
+void destroyImage8(Image8* i) {
|
|
|
+ stbi_image_free(i->data);
|
|
|
+ *i = (Image8){0};
|
|
|
}
|
|
|
|
|
|
-bool coreInitImage16(CoreImage16* image, const char* path) {
|
|
|
- *image = (CoreImage16){0};
|
|
|
- image->data =
|
|
|
- stbi_load_16(path, &image->width, &image->height, &image->channels, 0);
|
|
|
- if(image->data == nullptr) {
|
|
|
+bool initImage16(Image16* i, const char* path) {
|
|
|
+ *i = (Image16){0};
|
|
|
+ i->data = stbi_load_16(path, &i->width, &i->height, &i->channels, 0);
|
|
|
+ if(i->data == nullptr) {
|
|
|
printError(path);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-void coreDestroyImage16(CoreImage16* image) {
|
|
|
- stbi_image_free(image->data);
|
|
|
- *image = (CoreImage16){0};
|
|
|
+void destroyImage16(Image16* i) {
|
|
|
+ stbi_image_free(i->data);
|
|
|
+ *i = (Image16){0};
|
|
|
}
|