From 7a849bec978effa9a8d752e7fed92c028fafd57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 5 Apr 2016 15:31:13 -0700 Subject: [PATCH] texturec: Added error message when image width/height doesn't match target format requirements. --- tools/texturec/texturec.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/texturec/texturec.cpp b/tools/texturec/texturec.cpp index 12a5bda84..21d256ffb 100644 --- a/tools/texturec/texturec.cpp +++ b/tools/texturec/texturec.cpp @@ -477,6 +477,19 @@ int main(int _argc, const char* _argv[]) ImageMip dstMip; imageGetRawData(imageContainer, 0, 0, NULL, 0, dstMip); + if (mip.m_width != dstMip.m_width + && mip.m_height != dstMip.m_height) + { + printf("Invalid input image size %dx%d, it must be at least %dx%d to be converted to %s format.\n" + , mip.m_width + , mip.m_height + , dstMip.m_width + , dstMip.m_height + , getName(format) + ); + return EXIT_FAILURE; + } + uint32_t size = imageGetSize(TextureFormat::RGBA32F, dstMip.m_width, dstMip.m_height); temp = BX_ALLOC(&allocator, size); float* rgba = (float*)temp; @@ -528,6 +541,19 @@ int main(int _argc, const char* _argv[]) ImageMip dstMip; imageGetRawData(imageContainer, 0, 0, NULL, 0, dstMip); + if (mip.m_width != dstMip.m_width + && mip.m_height != dstMip.m_height) + { + printf("Invalid input image size %dx%d, it must be at least %dx%d to be converted to %s format.\n" + , mip.m_width + , mip.m_height + , dstMip.m_width + , dstMip.m_height + , getName(format) + ); + return EXIT_FAILURE; + } + uint32_t size = imageGetSize(TextureFormat::RGBA8, dstMip.m_width, dstMip.m_height); temp = BX_ALLOC(&allocator, size); memset(temp, 0, size);