Compare commits
10 Commits
6e15b0ec59
...
r110
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ab94a1cb8 | |||
| a18368acd2 | |||
| c56cbd741b | |||
| ef80b0faba | |||
| 832ba66295 | |||
| 1562bf60e8 | |||
| 852052174e | |||
| 9f39760ac9 | |||
| 0773588f4e | |||
| 8ab9227b25 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,5 +2,7 @@
|
||||
.idea
|
||||
/.vs
|
||||
/Debug
|
||||
/Release
|
||||
/x64
|
||||
/KAvEAT
|
||||
/x64/Debug
|
||||
/inno/out
|
||||
|
||||
@@ -23,28 +23,32 @@
|
||||
<ProjectGuid>{8C76412E-908C-4071-96B7-AC9428CB56E0}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectName>KAvEAT</ProjectName>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -82,15 +86,17 @@
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>C:\Program Files %28x86%29\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>CORE_RL_MagickWand_.lib;CORE_RL_MagickCore_.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>C:\Program Files\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>C:\Program Files %28x86%29\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -99,6 +105,8 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -111,9 +119,11 @@
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>C:\Program Files %28x86%29\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -121,7 +131,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>CORE_RL_MagickWand_.lib;CORE_RL_MagickCore_.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>C:\Program Files\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>C:\Program Files %28x86%29\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -130,6 +140,8 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
||||
82
inno/setup.iss
Normal file
82
inno/setup.iss
Normal file
@@ -0,0 +1,82 @@
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "KAvEAT"
|
||||
#define MyAppVersion "1.1.0"
|
||||
#define MyAppPublisher "bonkmaykr"
|
||||
#define MyAppURL "https://kangworlds.net/"
|
||||
#define MyAppUpdateURL "https://git.worlio.com/bonkmaykr/KAvEAT/releases"
|
||||
#define MyAppSourceURL "https://git.worlio.com/bonkmaykr/KAvEAT"
|
||||
#define MyAppExeName "KAvEAT.exe"
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{71FB8A33-47D3-454D-B814-FEC78C5226E8}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppSourceURL}
|
||||
AppUpdatesURL={#MyAppUpdateURL}
|
||||
DefaultDirName={autopf64}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
DisableProgramGroupPage=yes
|
||||
LicenseFile=C:\Users\kangang\source\repos\KAvEAT\LICENSE
|
||||
;PrivilegesRequiredOverridesAllowed=dialog
|
||||
OutputDir=C:\Users\kangang\source\repos\KAvEAT\inno\out
|
||||
OutputBaseFilename=kaveat
|
||||
SetupIconFile=C:\Users\kangang\source\repos\KAvEAT\kaveat.ico
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
WizardStyle=classic
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Files]
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_brotli_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_bzlib_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_cairo_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_exr_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_flif_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_freetype_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_fribidi_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_glib_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_harfbuzz_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_heif_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_jpeg-turbo_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_jpeg-xl_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_lcms_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_lqr_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_lzma_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_Magick++_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_MagickCore_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_MagickWand_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_openjpeg_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_pango_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_png_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_raw_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_rsvg_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_tiff_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_webp_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_xml_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zip_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zlib_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\mogrify.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{group}\Kangworlds.net"; Filename: "{#MyAppURL}"
|
||||
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
|
||||
|
||||
[Registry]
|
||||
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
|
||||
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"
|
||||
|
||||
[Messages]
|
||||
FinishedLabel=Setup has finished installing [name] on your computer. KAvEAT has been added to your system's PATH through the Windows Registry.
|
||||
ClickFinish=Run "KAvEAT.exe" from the command line (in any location on your computer) to use the program.
|
||||
BIN
kaveat.ico
Normal file
BIN
kaveat.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 131 KiB |
162
main.c
162
main.c
@@ -3,6 +3,9 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <MagickWand/MagickWand.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
int isPowerOfTwo(int x) {return x && (!(x & (x - 1)));}
|
||||
|
||||
@@ -32,13 +35,14 @@ unsigned int nearest_power_of_2(unsigned int n) {
|
||||
}
|
||||
|
||||
struct options {
|
||||
int r;
|
||||
uint32_t r;
|
||||
int s;
|
||||
uint8_t c;
|
||||
int o;
|
||||
int l;
|
||||
int w;
|
||||
int h;
|
||||
int d;
|
||||
};
|
||||
|
||||
void printHelp() {
|
||||
@@ -48,6 +52,11 @@ void printHelp() {
|
||||
"A maximum of 360 different frames can be used for a single avatar.\n"
|
||||
"If the size of any frame does not match, it will be resized to match the first frame.\n"
|
||||
"\n"
|
||||
"When using KAvEAT to create environment textures, please keep in mind that Worlds has\n"
|
||||
"a limit of 9x9 tiles per CMP/MOV file due to the URL parser only reading single digits.\n"
|
||||
"This makes the practical maximum resolution of avatars 2048x2048. World textures can not\n"
|
||||
"have more than 9 frames but can bypass both limits by splitting walls into more pieces.\n"
|
||||
"\n"
|
||||
"Available options:\n"
|
||||
" -r # Maximum resolution, where # is a power of 2. For example, 256 pixels would be \"-r 8\"\n"
|
||||
" -s Stretch the image when non-pot or mismatched size, as opposed to fitting it within.\n"
|
||||
@@ -57,6 +66,8 @@ void printHelp() {
|
||||
" so using this setting with different image sizes will cause visible bars to appear\n"
|
||||
" unless you combine it with the -s option, which will always fill the canvas for each\n"
|
||||
" frame. The same is true for all imported frames which contain an alpha channel.\n"
|
||||
" -d Don't run COMPIMG, don't delete temporary files. Useful if COMPIMG is broken for some\n"
|
||||
" reason, or if you want to customize the command line options given to it.\n"
|
||||
// " -l Enable Lanczos filtering when scaling the image.\n" //point filter unimplemented
|
||||
//" -w Specify the number of subdivisions to make horizontally per frame.\n"
|
||||
//" Use this if you are importing a spritesheet. Each cut is perfectly even.\n"
|
||||
@@ -66,20 +77,30 @@ void printHelp() {
|
||||
//" -h Same as -w, but vertical. If used with -w, KAvEAT will create each chunk\n"
|
||||
//" from each row left-to-right first, not each column top-to-bottom.\n"
|
||||
);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
DWORD procIDs[2];
|
||||
DWORD maxCount = 2;
|
||||
if (GetConsoleProcessList((LPDWORD)procIDs, maxCount) == 1) {
|
||||
printf("\n\nTHIS PROGRAM IS DESIGNED FOR USE WITH A TERMINAL.\n"
|
||||
"Please run cmd.exe first! Then you can use the tool.\n");
|
||||
system("pause");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void printNoFrames() {
|
||||
printf("You need to specify at least one frame to use, goober.\n");
|
||||
}
|
||||
void printNoFrames() { printf("You need to specify at least one frame to use, goober.\n"); }
|
||||
|
||||
int main(const int argc, char *argv[]) {
|
||||
printf(
|
||||
"Knowledge Adventure Worlds Easy Avatar Tool, version 1\n"
|
||||
"Knowledge Adventure Worlds Easy Avatar Tool, version 1.1\n"
|
||||
"Copyright (c) 2025 Brett \"bonkmaykr\" Bergstrom\n"
|
||||
"This program is free software under the MIT license.\n"
|
||||
"\n"
|
||||
);
|
||||
if (argc < 2) { printHelp(); return 0; }
|
||||
// Strings allocated with variable size according to filename need to be done on the heap due to an MSVC bug.
|
||||
char* filename = (char*)malloc(strlen(argv[1])*sizeof(char)); // MSVC
|
||||
strcpy(filename, argv[1]);
|
||||
printf("Creating avatar %s.mov\n", filename);
|
||||
@@ -97,32 +118,48 @@ int main(const int argc, char *argv[]) {
|
||||
opt.l = 0;
|
||||
opt.w = 0;
|
||||
opt.h = 0;
|
||||
opt.d = 0;
|
||||
uint16_t numFrames = 0;
|
||||
char* frames[360];
|
||||
|
||||
int i = 2;
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '+') {
|
||||
frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1);
|
||||
memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1);
|
||||
printf("Adding frame to search index: %s\n", frames[numFrames]);
|
||||
|
||||
numFrames++;
|
||||
} else if (argv[i] == "-r") {
|
||||
if (numFrames < 360) {
|
||||
frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1);
|
||||
memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1);
|
||||
printf("Adding frame to search index: %s\n", frames[numFrames]);
|
||||
|
||||
numFrames++;
|
||||
} else printf("REJECTING new frame as it exceeds the frame limit.\n");
|
||||
} else if (strcmp(argv[i], "-r") == 0) {
|
||||
if (i == argc-1) { printf("No parameter for option: -r\n"); return 0; }
|
||||
int r = pow(2, trunc(atof(argv[i+1])));
|
||||
if (r > 4096) { printf("I really, really hope your image is not %d pixels in size.\n", r); }
|
||||
else if (r < 2) {printf("I'm sorry, Dave, I'm afraid I can't do that. (%d pixel(s) is too small, clamping to 2.)\n", r); r = 2;}
|
||||
printf("Limiting resolution per frame to %dx%d pixels.\n", r, r);
|
||||
opt.r = r;
|
||||
i++;
|
||||
} else if (strcmp(argv[i], "-s") == 0) {
|
||||
opt.s = 1;
|
||||
} else if (argv[i] == "-o") {
|
||||
|
||||
} else if (argv[i] == "-b") {
|
||||
|
||||
opt.s = !opt.s;
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
opt.o = !opt.o;
|
||||
} else if (strcmp(argv[i], "-c") == 0) {
|
||||
if (i == argc-1) { printf("No parameter for option: -c\n"); return 0; }
|
||||
const int c = trunc(atof(argv[i+1]));
|
||||
if (c < 1 || c > 256) { printf("Invalid number of colors: %s\n", argv[i+1]); return 0; }
|
||||
opt.c = c - 1;
|
||||
i++;
|
||||
} else if (strcmp(argv[i], "-d") == 0) {
|
||||
opt.d = !opt.d;
|
||||
} else {
|
||||
printf("I don't know what \"%s\" means!\n", argv[i]);
|
||||
return 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
printf("Importing %d frames...\n", numFrames);
|
||||
if (numFrames == 0) { printNoFrames(); return 0; }
|
||||
|
||||
if (MagickReadImage(mw, frames[0]) == MagickFalse) { printf("ERROR trying to read %s\n", frames[0]); return 0;}
|
||||
MagickSetImageFormat(mw, "BMP3");
|
||||
MagickSetImageDepth(mw, 8);
|
||||
@@ -131,6 +168,57 @@ int main(const int argc, char *argv[]) {
|
||||
uint16_t width = MagickGetImageWidth(mw);
|
||||
uint16_t height = MagickGetImageHeight(mw);
|
||||
|
||||
// -r option
|
||||
if (opt.r > 0) {
|
||||
if (opt.s > 0) {
|
||||
printf("Squishing to resolution limit...\n");
|
||||
if (width > opt.r) {
|
||||
MagickResizeImage(mw, nearest_power_of_2(width), nearest_power_of_2(height), LanczosFilter);
|
||||
width = opt.r;
|
||||
}
|
||||
if (height > opt.r) {
|
||||
MagickResizeImage(mw, nearest_power_of_2(width), nearest_power_of_2(height), LanczosFilter);
|
||||
height = opt.r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Fitting to resolution limit...\n");
|
||||
if (width > opt.r || height > opt.r) {
|
||||
if (width > height) {
|
||||
const double ratio = (double)height/(double)width;
|
||||
printf("Letterboxing image to %ux%u.\n", opt.r, opt.r*ratio);
|
||||
PixelWand* pw = NewPixelWand();
|
||||
MagickGetImagePixelColor(mw, 0, 0, pw);
|
||||
MagickSetImageBackgroundColor(mw, pw);
|
||||
|
||||
if (ratio < 1) MagickResizeImage(mw, opt.r, opt.r*ratio, LanczosFilter);
|
||||
//MagickExtentImage(mw, opt.r, opt.r, 0, (opt.r-(opt.r*ratio))*-0.5);
|
||||
|
||||
width = opt.r;
|
||||
height = opt.r;
|
||||
} else if (height > width) {
|
||||
const double ratio = (double)width / (double)height;
|
||||
printf("Pillarboxing image to %ux%u.\n", opt.r*ratio, opt.r);
|
||||
PixelWand* pw = NewPixelWand();
|
||||
MagickGetImagePixelColor(mw, 0, 0, pw);
|
||||
MagickSetImageBackgroundColor(mw, pw);
|
||||
|
||||
if (ratio < 1) MagickResizeImage(mw, opt.r*ratio, opt.r, LanczosFilter);
|
||||
//MagickExtentImage(mw, opt.r, opt.r, (opt.r-(opt.r*ratio))*-0.5, 0);
|
||||
|
||||
width = opt.r;
|
||||
height = opt.r;
|
||||
} else /*if (height == width)*/ {
|
||||
printf("Resizing image to %ux%u.\n", opt.r, opt.r);
|
||||
MagickResizeImage(mw, opt.r, opt.r, LanczosFilter);
|
||||
|
||||
width = opt.r;
|
||||
height = opt.r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPowerOfTwo(width) || !isPowerOfTwo(height)) printf("Uh-oh! Image size %hux%hu is not a power of two!\n", width, height);
|
||||
if (opt.s > 0 || (!isPowerOfTwo(width) && !isPowerOfTwo(height))) { // both are bad!
|
||||
printf("Resizing image to %ux%u.\n", nearest_power_of_2(width), nearest_power_of_2(height));
|
||||
@@ -162,6 +250,8 @@ int main(const int argc, char *argv[]) {
|
||||
double ratio2;
|
||||
PixelWand* pw = NewPixelWand();
|
||||
MagickGetImagePixelColor(mw, 0, 0, pw);
|
||||
|
||||
printf("Importing %d frames...\n", numFrames);
|
||||
i = 1;
|
||||
while (i < numFrames) {
|
||||
// Letterbox background default to transparent pixel
|
||||
@@ -230,6 +320,11 @@ int main(const int argc, char *argv[]) {
|
||||
|
||||
MagickWriteImage(chunk, framename);
|
||||
|
||||
char* command = (char*)malloc(512); // lazy hack until magickwand is fixed
|
||||
sprintf(command, "mogrify -depth 8 -define bmp:format=bmp3 -type palette -compress none %s", framename);
|
||||
system(command);
|
||||
free(command);
|
||||
|
||||
iw++;
|
||||
}
|
||||
ih++;
|
||||
@@ -238,15 +333,42 @@ int main(const int argc, char *argv[]) {
|
||||
}
|
||||
fclose(partlist);
|
||||
|
||||
if (!opt.d) {
|
||||
// Pass on images to COMPIMG
|
||||
printf("Encoding texture file...\n");
|
||||
char* command = (char*)malloc((54 + 3 * opt.o + strlen(filename))*sizeof(char)); // MSVC
|
||||
char* command = (char*)malloc((54 + 3 * abs(1-opt.o) + strlen(filename))*sizeof(char)); // MSVC
|
||||
char argTransparent[3];
|
||||
if (opt.o == 0) sprintf(argTransparent, " -t");
|
||||
#ifdef _MSC_VER
|
||||
sprintf(command, "compimg.exe -ace -c%d -r0 -pt%s -emov -M%s +segments.txt", opt.c + 1, argTransparent, filename);
|
||||
#else
|
||||
sprintf(command, "./compimg.exe -ace -c%d -r0 -pt%s -emov -M%s +segments.txt", opt.c+1, argTransparent, filename);
|
||||
if (system(command)) { printf("ERROR trying to run COMPIMG!\n"); return 0; }
|
||||
#endif
|
||||
printf("%s\n", command);
|
||||
if (system(command)) { printf("ERROR trying to run COMPIMG!\nMake sure that COMPIMG.EXE is inside of the folder you are working in.\n"); }
|
||||
|
||||
printf("\n\n!!! DONE !!!\nYour avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY);
|
||||
printf("Cleaning up temporary files...\n");
|
||||
while (i < numFrames) {
|
||||
int ih = 0;
|
||||
while (ih < piecesY) {
|
||||
int iw = 0;
|
||||
while (iw < piecesX) {
|
||||
char* framename = (char*)malloc(12 * piecesX * piecesY * sizeof(char)); // MSVC
|
||||
sprintf(framename, "f%d%d%d.bmp", i, iw, ih);
|
||||
remove(framename);
|
||||
free(framename);
|
||||
|
||||
iw++;
|
||||
}
|
||||
ih++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\n!!! DONE !!!\n");
|
||||
if (opt.d)
|
||||
printf("Your avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY);
|
||||
|
||||
if(mw) mw = DestroyMagickWand(mw);
|
||||
MagickWandTerminus();
|
||||
|
||||
Reference in New Issue
Block a user