|
@@ -44,6 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
*/
|
|
|
|
|
|
#include "Main.h"
|
|
|
+#include <../code/fast_atof.h>
|
|
|
+#include <../code/StringComparison.h>
|
|
|
|
|
|
const char* AICMD_MSG_DUMP_HELP_E =
|
|
|
"assimp extract <model> [<out>] [-t<n>] [-f<fmt>] [-ba] [-s] [common parameters]\n"
|
|
@@ -118,7 +120,9 @@ struct TGA_HEADER
|
|
|
// Save a texture as bitmap
|
|
|
int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int height, bool SaveAlpha = false)
|
|
|
{
|
|
|
- if (!file || !data)return 1;
|
|
|
+ if (!file || !data) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
|
|
|
const unsigned int numc = (SaveAlpha ? 4 : 3);
|
|
|
unsigned char* buffer = new unsigned char[width*height*numc];
|
|
@@ -175,8 +179,9 @@ int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int
|
|
|
// Save a texture as tga
|
|
|
int SaveAsTGA (FILE* file, const aiTexel* data, unsigned int width, unsigned int height)
|
|
|
{
|
|
|
- if (!file || !data)return 1;
|
|
|
-
|
|
|
+ if (!file || !data) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
|
|
|
TGA_HEADER head = {0};
|
|
|
head.bits = 32;
|
|
@@ -220,8 +225,9 @@ int DoExport(const aiTexture* tx, FILE* p, const std::string& extension,
|
|
|
// Implementation of the assimp extract utility
|
|
|
int Assimp_Extract (const char* const* params, unsigned int num)
|
|
|
{
|
|
|
+ const char* const invalid = "assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n";
|
|
|
if (num < 1) {
|
|
|
- printf("assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n");
|
|
|
+ printf(invalid);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -233,7 +239,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|
|
|
|
|
// asssimp extract in out [options]
|
|
|
if (num < 1) {
|
|
|
- printf("assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n");
|
|
|
+ printf(invalid);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -250,7 +256,9 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|
|
// process other flags
|
|
|
std::string extension = "bmp";
|
|
|
for (unsigned int i = (out[0] == '-' ? 1 : 2); i < num;++i) {
|
|
|
- if (!params[i])continue;
|
|
|
+ if (!params[i]) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
if (!strncmp( params[i], "-f",2)) {
|
|
|
extension = std::string(params[i]+2);
|
|
@@ -262,10 +270,10 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|
|
nosuffix = true;
|
|
|
}
|
|
|
else if ( !strncmp( params[i], "--texture=",10)) {
|
|
|
- texIdx = ::strtol10(params[i]+10);
|
|
|
+ texIdx = Assimp::strtoul10(params[i]+10);
|
|
|
}
|
|
|
else if ( !strncmp( params[i], "-t",2)) {
|
|
|
- texIdx = ::strtol10(params[i]+2);
|
|
|
+ texIdx = Assimp::strtoul10(params[i]+2);
|
|
|
}
|
|
|
else if ( !strcmp( params[i], "-ba") || !strcmp( params[i], "--bmp-with-alpha")) {
|
|
|
flags |= AI_EXTRACT_WRITE_BMP_ALPHA;
|
|
@@ -277,9 +285,9 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
- for (std::string::iterator it = extension.begin();it != extension.end();++it)
|
|
|
- *it = ::tolower(*it);
|
|
|
|
|
|
+ std::transform(extension.begin(),extension.end(),extension.begin(),::tolower);
|
|
|
+
|
|
|
if (out[0] == '-') {
|
|
|
// take file name from input file
|
|
|
std::string::size_type s = in.find_last_of('.');
|
|
@@ -330,7 +338,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|
|
if (!nosuffix || (texIdx == 0xffffffff)) {
|
|
|
out_cpy.append ("_img");
|
|
|
char tmp[10];
|
|
|
- ASSIMP_itoa10(tmp,i);
|
|
|
+ Assimp::ASSIMP_itoa10(tmp,i);
|
|
|
|
|
|
out_cpy.append(std::string(tmp));
|
|
|
}
|