From 4a29607def1fa87a4ed5c54abcad2c1a84a78fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 18 Apr 2017 20:56:50 -0700 Subject: [PATCH] Added image resize. --- include/bimg/encode.h | 6 ++++++ scripts/bimg.lua | 1 + scripts/bimg_decode.lua | 1 + scripts/bimg_encode.lua | 1 + src/image_encode.cpp | 22 ++++++++++++++++++++++ 5 files changed, 31 insertions(+) diff --git a/include/bimg/encode.h b/include/bimg/encode.h index 3e4b150..ffa1d72 100644 --- a/include/bimg/encode.h +++ b/include/bimg/encode.h @@ -57,6 +57,12 @@ namespace bimg , uint16_t _height ); + /// + bool imageResizeRgba32fLinear( + ImageContainer* _dst + , const ImageContainer* _src + ); + } // namespace bimg #endif // BIMG_ENCODE_H_HEADER_GUARD diff --git a/scripts/bimg.lua b/scripts/bimg.lua index 8bf6e3a..b1f56d1 100644 --- a/scripts/bimg.lua +++ b/scripts/bimg.lua @@ -12,6 +12,7 @@ project "bimg" } files { + path.join(BIMG_DIR, "include/**"), path.join(BIMG_DIR, "src/image.*"), } diff --git a/scripts/bimg_decode.lua b/scripts/bimg_decode.lua index 934cbec..743d0ec 100644 --- a/scripts/bimg_decode.lua +++ b/scripts/bimg_decode.lua @@ -15,6 +15,7 @@ project "bimg_decode" } files { + path.join(BIMG_DIR, "include/**"), path.join(BIMG_DIR, "src/image_decode.*"), } diff --git a/scripts/bimg_encode.lua b/scripts/bimg_encode.lua index 1b853f6..44021dc 100644 --- a/scripts/bimg_encode.lua +++ b/scripts/bimg_encode.lua @@ -15,6 +15,7 @@ project "bimg_encode" } files { + path.join(BIMG_DIR, "include/**"), path.join(BIMG_DIR, "src/image_encode.*"), path.join(BIMG_DIR, "3rdparty/libsquish/**.cpp"), path.join(BIMG_DIR, "3rdparty/libsquish/**.h"), diff --git a/src/image_encode.cpp b/src/image_encode.cpp index ed005d2..c0ce14f 100644 --- a/src/image_encode.cpp +++ b/src/image_encode.cpp @@ -12,6 +12,13 @@ #include #include +BX_PRAGMA_DIAGNOSTIC_PUSH(); +BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4100) // warning C4100: 'alloc_context': unreferenced formal parameter +BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4702) // warning C4702: unreachable code +#define STB_IMAGE_RESIZE_IMPLEMENTATION +#include +BX_PRAGMA_DIAGNOSTIC_POP(); + extern "C" { #include } @@ -301,4 +308,19 @@ namespace bimg return result; } + bool imageResizeRgba32fLinear(ImageContainer* _dst, const ImageContainer* _src) + { + int result = stbir_resize_float_generic( + (const float*)_src->m_data, _src->m_width, _src->m_height, _src->m_width*16 + , ( float*)_dst->m_data, _dst->m_width, _dst->m_height, _dst->m_width*16 + , 4, 1 + , 0 + , STBIR_EDGE_CLAMP + , STBIR_FILTER_DEFAULT + , STBIR_COLORSPACE_LINEAR + , NULL + ); + return 1 == result; + } + } // namespace bimg