// ---------------------------------------------------------------------------- // CompactXVL (ALEX SDK sample) // Aron Gombas // (C) 3NF Corp. // ---------------------------------------------------------------------------- #include #include "ALEX.hpp" // ---------------------------------------------------------------------------- // // ---------------------------------------------------------------------------- const char *applicationName = "CompactXVL"; // ---------------------------------------------------------------------------- // // ---------------------------------------------------------------------------- /** * This sample program: * - embeds all the textures used * - converts their image format to JPEG */ int main (int argc, char *argv[]) { printf ("%s\n", applicationName); printf ("(%s %s)\n", __DATE__, __TIME__); printf ("Copyright (C) 2002 3NF Corporation. All rights reserved.\n"); printf ("support@3nf.com\n"); printf ("http://www.3nf.com\n\n"); printf ("Abstract Library for XVL, Version %s\n", ALEXVersion); printf ("Copyright (C) 2001-2002 3NF Corporation. All rights reserved.\n\n"); if (argc < 3) { printf ("Usage: %s inputfile outputfile\n", argv[0]); return 1; } // init XMLPlatformUtils::Initialize (); // load XVL printf ("Opening \"%s\"...\n", argv[1]); DOMDocument *doc = XVLFileIO::ReadXVL (argv[1]); // embed/convert all textures DOMNodeList *textureNodes = XVLTextureManager::GetTextureNodes (doc); for (long i = 0; i < textureNodes->getLength (); i++) { XVLTexture t ((DOMElement *)textureNodes->item (i)); StrX name (t.GetID ()); if (!t.IsEmbedded ()) { printf ("Embedding external texture \"%s\"...\n", name.localForm ()); t.EmbedImage (); } XVLConstants::IMAGEFORMAT format = t.GetImageFormat (); if (format != XVLConstants::BF_JPG) { printf ("Converting \"%s\" from \"%s\" to \"jpeg\"...\n", name.localForm (), XVLTexture::GetExtension (format)); t.ConvertEmbeddedImage (XVLConstants::BF_JPG); } } // save XVL printf ("Saving \"%s\"...\n", argv[2]); XVLFileIO::WriteXVL (argv[2], doc, 0); // close XMLPlatformUtils::Terminate (); return 0; }