Initial release

This commit is contained in:
civ
2026-08-16 18:24:52 +07:00
commit 876886a39a
13244 changed files with 2353959 additions and 0 deletions
@@ -0,0 +1,31 @@
set(TargetName uidesccompressor)
set(${TargetName}_sources
main.cpp
)
set(${TargetName}_PLATFORM_LIBS "")
if(CMAKE_HOST_APPLE)
set(${TargetName}_PLATFORM_LIBS
"-framework Cocoa"
"-framework OpenGL"
"-framework QuartzCore"
"-framework Accelerate"
"-framework CoreAudio"
)
endif()
add_executable(${TargetName}
${${TargetName}_sources}
)
target_link_libraries(${TargetName}
vstgui
vstgui_uidescription
${${TargetName}_PLATFORM_LIBS}
)
target_include_directories(${TargetName} PRIVATE ../../../)
vstgui_set_cxx_version(${TargetName} ${VSTGUI_CXX_VERSION})
set_target_properties(${TargetName} PROPERTIES ${APP_PROPERTIES} ${VSTGUI_TOOLS_FOLDER})
target_compile_definitions(${TargetName} ${VSTGUI_COMPILE_DEFINITIONS})
@@ -0,0 +1,113 @@
// This file is part of VSTGUI. It is subject to the license terms
// in the LICENSE file found in the top-level directory of this
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
#include "vstgui/lib/cresourcedescription.h"
#include "vstgui/lib/cstring.h"
#include "vstgui/lib/finally.h"
#include "vstgui/uidescription/compresseduidescription.h"
#include "vstgui/lib/vstguiinit.h"
#include <string>
//------------------------------------------------------------------------
#if MAC
#include <CoreFoundation/CoreFoundation.h>
#elif WINDOWS
struct IUnknown;
#include <windows.h>
#include <Shlobj.h>
#elif LINUX
#endif
using namespace VSTGUI;
//------------------------------------------------------------------------
void printAndTerminate (const char* msg)
{
if (msg)
printf ("%s\n", msg);
exit (-1);
}
//------------------------------------------------------------------------
int main (int argv, char* argc[])
{
#if MAC
VSTGUI::init (CFBundleGetMainBundle ());
#elif WINDOWS
CoInitialize (nullptr);
VSTGUI::init (GetModuleHandle (nullptr));
#elif LINUX
VSTGUI::init (nullptr);
#endif
auto cleanup = finally ([] () {VSTGUI::exit (); });
std::string inputPath;
std::string outputPath;
bool noCompression = false;
uint32_t compressionLevel = 1;
for (auto i = 0; i < argv; ++i)
{
UTF8StringView arg (argc[i]);
if (arg == "-i")
{
if (++i >= argv)
break;
inputPath = argc[i];
}
else if (arg == "-o")
{
if (++i >= argv)
break;
outputPath = argc[i];
}
else if (arg == "-c")
{
if (++i >= argv)
break;
compressionLevel = static_cast<uint32_t> (UTF8StringView (argc[i]).toInteger ());
}
else if (arg == "--nocompression")
{
noCompression = true;
}
}
if (inputPath.empty () || outputPath.empty ())
{
printAndTerminate ("No input or output path specified!");
}
printf ("Copy %s to %s%s\n", inputPath.data (), outputPath.data (),
noCompression ? " [uncompressed]" : "[compressed]");
CompressedUIDescription uiDesc (CResourceDescription (inputPath.data ()));
if (!uiDesc.parse ())
{
printAndTerminate ("Parsing failed!");
}
int32_t flags = UIDescription::kWriteImagesIntoUIDescFile;
if (noCompression)
{
if (inputPath == outputPath && uiDesc.getOriginalIsCompressed () == false)
return 0;
if (!uiDesc.UIDescription::save (outputPath.data (), flags))
{
printAndTerminate ("saving failed");
}
}
else
{
if (inputPath == outputPath && uiDesc.getOriginalIsCompressed () == true)
return 0;
flags |= CompressedUIDescription::kNoPlainUIDescFileBackup |
CompressedUIDescription::kForceWriteCompressedDesc |
CompressedUIDescription::kDoNotVerifyImageData;
uiDesc.setCompressionLevel (compressionLevel);
if (!uiDesc.save (outputPath.data (), flags))
{
printAndTerminate ("saving failed");
}
}
return 0;
}