diff --git a/.gitignore b/.gitignore index a9ac99f..25c7474 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /cmake-build-debug/ -.idea \ No newline at end of file +.idea +/.vs +/Debug +/KAvEAT +/x64/Debug diff --git a/CMakeLists.txt b/CMakeLists.txt index 79dd346..a810794 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 3.31) -project(kavat C) +cmake_minimum_required(VERSION 3.28) +project(kaveat C) set(CMAKE_C_STANDARD 11) -add_executable(kavat main.c) +add_executable(kaveat main.c) FIND_PACKAGE(ImageMagick REQUIRED @@ -14,6 +14,6 @@ add_compile_definitions(MAGICKCORE_HDRI_ENABLE=0) add_compile_definitions(MAGICKCORE_QUANTUM_DEPTH=8) set(CMAKE_SYSTEM_NAME Linux) -target_include_directories(kavat PUBLIC ${ImageMagick_INCLUDE_DIRS} ${ImageMagick_MagickWand_INCLUDE_DIRS}) -target_link_libraries(kavat m ${ImageMagick_LIBRARIES} ${ImageMagick_MagickWand_LIBRARY}) -target_link_directories(kavat PUBLIC ${ImageMagick_INCLUDE_DIRS} ${ImageMagick_MagickWand_INCLUDE_DIRS}) +target_include_directories(kaveat PUBLIC ${ImageMagick_INCLUDE_DIRS} ${ImageMagick_MagickWand_INCLUDE_DIRS}) +target_link_libraries(kaveat m ${ImageMagick_LIBRARIES} ${ImageMagick_MagickWand_LIBRARY}) +target_link_directories(kaveat PUBLIC ${ImageMagick_INCLUDE_DIRS} ${ImageMagick_MagickWand_INCLUDE_DIRS}) diff --git a/KAvEAT.sln b/KAvEAT.sln new file mode 100644 index 0000000..378fc81 --- /dev/null +++ b/KAvEAT.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35521.163 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KAvaT", "KAvaT.vcxproj", "{8C76412E-908C-4071-96B7-AC9428CB56E0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Debug|x64.ActiveCfg = Debug|x64 + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Debug|x64.Build.0 = Debug|x64 + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Debug|x86.ActiveCfg = Debug|Win32 + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Debug|x86.Build.0 = Debug|Win32 + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Release|x64.ActiveCfg = Release|x64 + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Release|x64.Build.0 = Release|x64 + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Release|x86.ActiveCfg = Release|Win32 + {8C76412E-908C-4071-96B7-AC9428CB56E0}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/KAvaT.vcxproj b/KAvaT.vcxproj new file mode 100644 index 0000000..d75aafa --- /dev/null +++ b/KAvaT.vcxproj @@ -0,0 +1,149 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + {8C76412E-908C-4071-96B7-AC9428CB56E0} + Win32Proj + KAvEAT + 8.1 + + + + Application + true + v141_xp + + + Application + false + v141_xp + + + Application + true + v141_xp + + + Application + false + v141_xp + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + $(VC_IncludePath);$(WindowsSdk_71A_IncludePath) + $(LibraryPath) + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + Level3 + C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories) + stdc11 + CompileAsCpp + + + true + Console + CORE_RL_MagickWand_.lib;CORE_RL_MagickCore_.lib;%(AdditionalDependencies) + C:\Program Files\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories) + + + + + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + Level3 + C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories) + CompileAsCpp + + + true + Console + C:\Program Files\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories) + CORE_RL_MagickWand_.lib;CORE_RL_MagickCore_.lib;%(AdditionalDependencies) + + + + + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + Level3 + C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories) + stdc11 + CompileAsCpp + + + true + Console + true + true + CORE_RL_MagickWand_.lib;CORE_RL_MagickCore_.lib;%(AdditionalDependencies) + C:\Program Files\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories) + + + + + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + Level3 + C:\Program Files\ImageMagick-7.1.1-Q16\include;%(AdditionalIncludeDirectories) + CompileAsCpp + + + true + Console + true + true + C:\Program Files\ImageMagick-7.1.1-Q16\lib;%(AdditionalLibraryDirectories) + CORE_RL_MagickWand_.lib;CORE_RL_MagickCore_.lib;%(AdditionalDependencies) + + + + + + + + + \ No newline at end of file diff --git a/KAvaT.vcxproj.filters b/KAvaT.vcxproj.filters new file mode 100644 index 0000000..a31ff86 --- /dev/null +++ b/KAvaT.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + \ No newline at end of file diff --git a/KAvaT.vcxproj.user b/KAvaT.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/KAvaT.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/main.c b/main.c index e622f51..fee2c00 100644 --- a/main.c +++ b/main.c @@ -43,14 +43,11 @@ struct options { void printHelp() { printf( - "usage: kavat [options]\n" + "usage: kaveat [options]\n" "Where each source begins with +, and is added as an animation frame.\n" "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" - "THIS PROGRAM IS DESIGNED FOR HOLOGRAMS ONLY. If you are making world textures.\n" - "you best learn how to run COMPIMG manually, please see https://kangworlds.net/tutorials/cmp\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" @@ -66,7 +63,7 @@ void printHelp() { //" Note that this process happens AFTER importing each image, and will be\n" //" applied to each one separately. DO NOT use this to combine a spritesheet" //" with individual frames or you will have a very, very bad time." - //" -h Same as -w, but vertical. If used with -w, KAvaT will create each chunk\n" + //" -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" ); } @@ -77,13 +74,14 @@ void printNoFrames() { int main(const int argc, char *argv[]) { printf( - "Knowledge Adventure Worlds Avatar Tool, version 1\n" + "Knowledge Adventure Worlds Easy Avatar Tool, version 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; } - char filename[strlen(argv[1])]; strcpy(filename, argv[1]); + char* filename = (char*)malloc(strlen(argv[1])*sizeof(char)); // MSVC + strcpy(filename, argv[1]); printf("Creating avatar %s.mov\n", filename); if (argc < 3) { printNoFrames(); return 0; } @@ -226,16 +224,12 @@ int main(const int argc, char *argv[]) { MagickCropImage(chunk, chunkw, chunkh, (chunkw*iw)+(width*i), chunkh*ih); printf("Saving frame #%d, chunk offset %d,%d\n", i+1, iw, ih); - char framename[12*piecesX*piecesY]; // this is stupid + char* framename = (char*)malloc(12 * piecesX * piecesY * sizeof(char)); // MSVC sprintf(framename, "f%d%d%d.bmp", i, iw, ih); fprintf(partlist, "f%d%d%d.bmp\n", i, iw, ih); MagickWriteImage(chunk, framename); - //char command[57 + 12*piecesX*piecesY]; // retard hack :)))))) because magickwand can't just do what i fucking ask - //sprintf(command, "mogrify -depth 8 -define bmp:format=bmp3 -type palette %s", framename); - //if (system(command)) { printf("ERROR trying to run mogrify! Is imagemagick installed to your PATH?\n"); return 0; } - iw++; } ih++; @@ -246,7 +240,7 @@ int main(const int argc, char *argv[]) { // Pass on images to COMPIMG printf("Encoding texture file...\n"); - char command[54 + 3*opt.o + strlen(filename)]; + char* command = (char*)malloc((54 + 3 * opt.o + strlen(filename))*sizeof(char)); // MSVC char argTransparent[3]; if (opt.o == 0) sprintf(argTransparent, " -t"); sprintf(command, "./compimg.exe -ace -c%d -r0 -pt%s -emov -M%s +segments.txt", opt.c+1, argTransparent, filename); @@ -256,5 +250,6 @@ int main(const int argc, char *argv[]) { if(mw) mw = DestroyMagickWand(mw); MagickWandTerminus(); + // don't clean up heap strings since the OS will reclaim the memory anyway return 0; } \ No newline at end of file