diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt index ec4d2eec..80d7fad4 100644 --- a/lua/CMakeLists.txt +++ b/lua/CMakeLists.txt @@ -44,7 +44,7 @@ if(BUILD_X11) endif(BUILD_LUA_CAIRO) if(BUILD_LUA_IMLIB2) - include_directories(${luaimlib2_includes} ${CMAKE_CURRENT_SOURCE_DIR}) + include_directories(${luaimlib2_includes} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) if(IMLIB2_VERSION VERSION_GREATER_EQUAL "1.10.0") wrap_tolua(luaimlib2_src imlib2.pkg) diff --git a/lua/libcairo_imlib2_helper.h b/lua/libcairo_imlib2_helper.h index 59c23d0f..4523d0c5 100644 --- a/lua/libcairo_imlib2_helper.h +++ b/lua/libcairo_imlib2_helper.h @@ -28,6 +28,8 @@ #include #include +#include "logging.h" + void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, double scale_x, double scale_y, double *return_scale_w, double *return_scale_h) { @@ -36,14 +38,25 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, Imlib_Image alpha, premul; cairo_surface_t *result; cairo_t *cr; + + if (!file) { + NORM_ERR("cairoimagehelper: File is NULL\n"); + return; + } + + if (!cs) { + NORM_ERR("cairoimagehelper: Surface is NULL\n"); + return; + } + Imlib_Image *image = imlib_load_image(file); if (!image) { - printf("Error: CairoImageHelper: Couldn't load %s\n", file); + NORM_ERR("cairoimagehelper: Couldn't load %s\n", file); return; } if ((scale_x <= 0.0) && (scale_y <= 0.0)) { - printf("Error: CairoImageHelper: Image Scale is 0, %s\n", file); + NORM_ERR("cairoimagehelper: Image Scale is 0, %s\n", file); return; } @@ -52,7 +65,7 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, h = imlib_image_get_height(); if ((w <= 0) && (h <= 0)) { - printf("Error: CairoImageHelper: %s has 0 size\n", file); + NORM_ERR("cairoimagehelper: %s has 0 size\n", file); return; } @@ -60,7 +73,7 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, scaled_h = *return_scale_h = scale_y * (double)h; if ((scaled_w <= 0.0) && (scaled_h <= 0.0)) { - printf("Error: CairoImageHelper: %s scaled image has 0 size\n", file); + NORM_ERR("cairoimagehelper: %s scaled image has 0 size\n", file); return; } @@ -70,7 +83,7 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, /* create temporary image */ premul = imlib_create_image(scaled_w, scaled_h); if (!premul) { - printf("Error: CairoImageHelper: Couldn't create premul image for %s\n", file); + NORM_ERR("cairoimagehelper: Couldn't create premul image for %s\n", file); return; }