3 #include "nel/misc/bitmap.h"
4 #include "nel/misc/file.h"
8 using namespace NLMISC
;
14 printf("Usage: tga_resize tgaFileIn tgaFileOut divideRatio.\n \
15 eg: tga_resize pipo.tga pipo.tga 2\n \
16 => pipo.tga widht and height are divided by 2 \n\n");
21 int main(int argc
, char *argv
[])
35 NLMISC::fromString(argv
[3], divideRatio
);
36 if(divideRatio
==0 || !isPowerOf2(divideRatio
))
38 printf("divideRatio must be a powerOf2 (1, 2, 4, 8 ...) \n");
45 if (!inFile
.open(argv
[1]))
47 printf("Can't open input file %s \n", argv
[1]);
50 uint8 depth
= btmp
.load(inFile
);
52 throw Exception("Bad File Format");
56 btmp
.resample(btmp
.getWidth() / divideRatio
, btmp
.getHeight() / divideRatio
);
59 if (!outFile
.open(argv
[2]))
61 printf("Can't open output file %s \n", argv
[2]);
64 btmp
.writeTGA(outFile
, depth
);
66 catch (const Exception
&e
)
68 printf("Error: %s\n", e
.what());