0.2.0-dev Download ZIP
74 lines ·4.2 KB Raw
| 1 | /**************************************************************************/ |
| 2 | /* image.compat.inc */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #ifndef DISABLE_DEPRECATED |
| 32 | |
| 33 | #include "core/object/class_db.h" |
| 34 | |
| 35 | static Image::CompressProfile _astc_format_to_compress_profile(Image::ASTCFormat p_format) { |
| 36 | switch (p_format) { |
| 37 | case Image::ASTC_FORMAT_4x4: |
| 38 | return Image::COMPRESS_PROFILE_MAX_QUALITY; |
| 39 | case Image::ASTC_FORMAT_8x8: |
| 40 | return Image::COMPRESS_PROFILE_MAX_COMPRESSION; |
| 41 | default: |
| 42 | return Image::COMPRESS_PROFILE_AUTOMATIC; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | Error Image::_compress_bind_compat_115003(CompressMode p_mode, CompressSource p_source, ASTCFormat p_format) { |
| 47 | return compress(p_mode, p_source, _astc_format_to_compress_profile(p_format)); |
| 48 | } |
| 49 | |
| 50 | Error Image::_compress_from_channels_bind_compat_115003(CompressMode p_mode, UsedChannels p_channels, ASTCFormat p_format) { |
| 51 | return compress_from_channels(p_mode, p_channels, _astc_format_to_compress_profile(p_format)); |
| 52 | } |
| 53 | |
| 54 | Error Image::_generate_mipmaps_bind_compat_104289(bool p_renormalize) { |
| 55 | return generate_mipmaps(p_renormalize, false, 0.5f); |
| 56 | } |
| 57 | |
| 58 | Vector<uint8_t> Image::_save_exr_to_buffer_bind_compat_117800(bool p_grayscale) const { |
| 59 | return save_exr_to_buffer(p_grayscale); |
| 60 | } |
| 61 | |
| 62 | Error Image::_save_exr_bind_compat_117800(const String &p_path, bool p_grayscale) const { |
| 63 | return save_exr(p_path, p_grayscale); |
| 64 | } |
| 65 | |
| 66 | void Image::_bind_compatibility_methods() { |
| 67 | ClassDB::bind_compatibility_method(D_METHOD("compress", "mode", "source", "astc_format"), &Image::_compress_bind_compat_115003, DEFVAL(COMPRESS_SOURCE_GENERIC), DEFVAL(ASTC_FORMAT_4x4)); |
| 68 | ClassDB::bind_compatibility_method(D_METHOD("compress_from_channels", "mode", "channels", "astc_format"), &Image::_compress_from_channels_bind_compat_115003, DEFVAL(ASTC_FORMAT_4x4)); |
| 69 | ClassDB::bind_compatibility_method(D_METHOD("generate_mipmaps", "renormalize"), &Image::_generate_mipmaps_bind_compat_104289, DEFVAL(false)); |
| 70 | ClassDB::bind_compatibility_method(D_METHOD("save_exr", "path", "grayscale"), &Image::_save_exr_bind_compat_117800, DEFVAL(false)); |
| 71 | ClassDB::bind_compatibility_method(D_METHOD("save_exr_to_buffer", "grayscale"), &Image::_save_exr_to_buffer_bind_compat_117800, DEFVAL(false)); |
| 72 | } |
| 73 | |
| 74 | #endif // DISABLE_DEPRECATED |