diff options
| author | xolatile | 2025-04-20 15:13:58 +0200 |
|---|---|---|
| committer | xolatile | 2025-04-20 15:13:58 +0200 |
| commit | b2bbfd7be69c1de91a06d922a9f7e09b45e59c1e (patch) | |
| tree | d0b0e5bb6e3eec2e6a8538d4394f1af09edaf2cf /xormat.h | |
| download | xolatile-xarbon-master.tar.xz xolatile-xarbon-master.tar.zst | |
Diffstat (limited to 'xormat.h')
| -rw-r--r-- | xormat.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/xormat.h b/xormat.h new file mode 100644 index 0000000..59cf66d --- /dev/null +++ b/xormat.h @@ -0,0 +1,122 @@ +/// _ +/// __ _____ _ __ _ __ ___ __ _| |_ +/// \ \/ / _ \| '__| '_ ` _ \ / _` | __| +/// > < (_) | | | | | | | | (_| | |_ +/// /_/\_\___/|_| |_| |_| |_|\__,_|\__| +/// +/// Copyright (c) 1997 - Ognjen 'xolatile' Milan Robovic +/// +/// xolatile@chud.cyou - xormat - Very simple file format wrapper for things I hate but have to use anyway... +/// +/// This program is free software, free as in freedom and as in free beer, you can redistribute it and/or modify it under the terms of the GNU +/// General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version if you wish... +/// +/// This program is distributed in the hope that it will be useful, but it is probably not, and without any warranty, without even the implied +/// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License +/// for more details, if you dare, it is a lot of text that nobody wants to read... + +#ifdef use_png_library +#include "xormat/png.h" +#endif + +#ifdef use_jxl_library +#include "xormat/jxl.h" +#endif + +#ifdef use_jpg_library +#include "xormat/jpg.h" +#endif + +#ifdef use_tga_library +#include "xormat/tga.h" +#endif + +static generic * format_image_import (character * path, natural * width, natural * height) { + natural * data = null; + +#ifdef use_png_library + if (data == null) { + character buffer [256] = ""; + + if (file_exists (string_concatenate (string_copy (buffer, path), ".png")) == true) { + data = png_image_import (buffer, width, height); + } + } +#endif + +#ifdef use_jxl_library + if (data == null) { + character buffer [256] = ""; + + if (file_exists (string_concatenate (string_copy (buffer, path), ".jxl")) == true) { + data = jxl_image_import (buffer, width, height); + } + } +#endif + +#ifdef use_jpg_library + if (data == null) { + character buffer [256] = ""; + + if (file_exists (string_concatenate (string_copy (buffer, path), ".jpg")) == true) { + data = jpg_image_import (buffer, width, height); + } + } +#endif + +#ifdef use_tga_library + if (data == null) { + character buffer [256] = ""; + + if (file_exists (string_concatenate (string_copy (buffer, path), ".tga")) == true) { + data = tga_image_import (buffer, width, height); + } + } +#endif + + if (data == null) { + switch (file_type (path)) { +#ifdef use_png_library + case (file_type_png_image): { + if (file_exists (path) == true) { + data = png_image_import (path, width, height); + } else { + print ("/w File '/3%s/-' doesn't exist.\n", path); + } + } break; +#endif +#ifdef use_jxl_library + case (file_type_jxl_image): { + if (file_exists (path) == true) { + data = jxl_image_import (path, width, height); + } else { + print ("/w File '/3%s/-' doesn't exist.\n", path); + } + } break; +#endif +#ifdef use_jpg_library + case (file_type_jpg_image): { + if (file_exists (path) == true) { + data = jpg_image_import (path, width, height); + } else { + print ("/w File '/3%s/-' doesn't exist.\n", path); + } + } break; +#endif +#ifdef use_tga_library + case (file_type_tga_image): { + if (file_exists (path) == true) { + data = tga_image_import (path, width, height); + } else { + print ("/w File '/3%s/-' doesn't exist.\n", path); + } + } break; +#endif + default: { + print ("/w File '/3%s/-' doesn't exist or file type isn't supported.\n", path); + } break; + } + } + + return (data); +} |
