diff options
Diffstat (limited to 'core/image.cpp')
-rw-r--r-- | core/image.cpp | 126 |
1 files changed, 66 insertions, 60 deletions
diff --git a/core/image.cpp b/core/image.cpp index 2db9cb1571..bb1ce2cee3 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -343,6 +343,11 @@ int Image::get_height() const { return height; } +Vector2 Image::get_size() const { + + return Vector2(width, height); +} + bool Image::has_mipmaps() const { return mipmaps; @@ -676,8 +681,8 @@ void Image::resize_to_po2(bool p_square) { ERR_FAIL(); } - int w = nearest_power_of_2(width); - int h = nearest_power_of_2(height); + int w = next_power_of_2(width); + int h = next_power_of_2(height); if (w == width && h == height) { @@ -1060,7 +1065,7 @@ Error Image::generate_mipmaps() { PoolVector<uint8_t>::Write wp = data.write(); - if (nearest_power_of_2(width) == uint32_t(width) && nearest_power_of_2(height) == uint32_t(height)) { + if (next_power_of_2(width) == uint32_t(width) && next_power_of_2(height) == uint32_t(height)) { //use fast code for powers of 2 int prev_ofs = 0; int prev_h = height; @@ -2215,6 +2220,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("get_width"), &Image::get_width); ClassDB::bind_method(D_METHOD("get_height"), &Image::get_height); + ClassDB::bind_method(D_METHOD("get_size"), &Image::get_size); ClassDB::bind_method(D_METHOD("has_mipmaps"), &Image::has_mipmaps); ClassDB::bind_method(D_METHOD("get_format"), &Image::get_format); ClassDB::bind_method(D_METHOD("get_data"), &Image::get_data); @@ -2275,62 +2281,62 @@ void Image::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "_set_data", "_get_data"); - BIND_CONSTANT(FORMAT_L8); //luminance - BIND_CONSTANT(FORMAT_LA8); //luminance-alpha - BIND_CONSTANT(FORMAT_R8); - BIND_CONSTANT(FORMAT_RG8); - BIND_CONSTANT(FORMAT_RGB8); - BIND_CONSTANT(FORMAT_RGBA8); - BIND_CONSTANT(FORMAT_RGBA4444); - BIND_CONSTANT(FORMAT_RGBA5551); - BIND_CONSTANT(FORMAT_RF); //float - BIND_CONSTANT(FORMAT_RGF); - BIND_CONSTANT(FORMAT_RGBF); - BIND_CONSTANT(FORMAT_RGBAF); - BIND_CONSTANT(FORMAT_RH); //half float - BIND_CONSTANT(FORMAT_RGH); - BIND_CONSTANT(FORMAT_RGBH); - BIND_CONSTANT(FORMAT_RGBAH); - BIND_CONSTANT(FORMAT_RGBE9995); - BIND_CONSTANT(FORMAT_DXT1); //s3tc bc1 - BIND_CONSTANT(FORMAT_DXT3); //bc2 - BIND_CONSTANT(FORMAT_DXT5); //bc3 - BIND_CONSTANT(FORMAT_RGTC_R); - BIND_CONSTANT(FORMAT_RGTC_RG); - BIND_CONSTANT(FORMAT_BPTC_RGBA); //btpc bc6h - BIND_CONSTANT(FORMAT_BPTC_RGBF); //float / - BIND_CONSTANT(FORMAT_BPTC_RGBFU); //unsigned float - BIND_CONSTANT(FORMAT_PVRTC2); //pvrtc - BIND_CONSTANT(FORMAT_PVRTC2A); - BIND_CONSTANT(FORMAT_PVRTC4); - BIND_CONSTANT(FORMAT_PVRTC4A); - BIND_CONSTANT(FORMAT_ETC); //etc1 - BIND_CONSTANT(FORMAT_ETC2_R11); //etc2 - BIND_CONSTANT(FORMAT_ETC2_R11S); //signed ); NOT srgb. - BIND_CONSTANT(FORMAT_ETC2_RG11); - BIND_CONSTANT(FORMAT_ETC2_RG11S); - BIND_CONSTANT(FORMAT_ETC2_RGB8); - BIND_CONSTANT(FORMAT_ETC2_RGBA8); - BIND_CONSTANT(FORMAT_ETC2_RGB8A1); - BIND_CONSTANT(FORMAT_MAX); - - BIND_CONSTANT(INTERPOLATE_NEAREST); - BIND_CONSTANT(INTERPOLATE_BILINEAR); - BIND_CONSTANT(INTERPOLATE_CUBIC); - - BIND_CONSTANT(ALPHA_NONE); - BIND_CONSTANT(ALPHA_BIT); - BIND_CONSTANT(ALPHA_BLEND); - - BIND_CONSTANT(COMPRESS_S3TC); - BIND_CONSTANT(COMPRESS_PVRTC2); - BIND_CONSTANT(COMPRESS_PVRTC4); - BIND_CONSTANT(COMPRESS_ETC); - BIND_CONSTANT(COMPRESS_ETC2); - - BIND_CONSTANT(COMPRESS_SOURCE_GENERIC); - BIND_CONSTANT(COMPRESS_SOURCE_SRGB); - BIND_CONSTANT(COMPRESS_SOURCE_NORMAL); + BIND_ENUM_CONSTANT(FORMAT_L8); //luminance + BIND_ENUM_CONSTANT(FORMAT_LA8); //luminance-alpha + BIND_ENUM_CONSTANT(FORMAT_R8); + BIND_ENUM_CONSTANT(FORMAT_RG8); + BIND_ENUM_CONSTANT(FORMAT_RGB8); + BIND_ENUM_CONSTANT(FORMAT_RGBA8); + BIND_ENUM_CONSTANT(FORMAT_RGBA4444); + BIND_ENUM_CONSTANT(FORMAT_RGBA5551); + BIND_ENUM_CONSTANT(FORMAT_RF); //float + BIND_ENUM_CONSTANT(FORMAT_RGF); + BIND_ENUM_CONSTANT(FORMAT_RGBF); + BIND_ENUM_CONSTANT(FORMAT_RGBAF); + BIND_ENUM_CONSTANT(FORMAT_RH); //half float + BIND_ENUM_CONSTANT(FORMAT_RGH); + BIND_ENUM_CONSTANT(FORMAT_RGBH); + BIND_ENUM_CONSTANT(FORMAT_RGBAH); + BIND_ENUM_CONSTANT(FORMAT_RGBE9995); + BIND_ENUM_CONSTANT(FORMAT_DXT1); //s3tc bc1 + BIND_ENUM_CONSTANT(FORMAT_DXT3); //bc2 + BIND_ENUM_CONSTANT(FORMAT_DXT5); //bc3 + BIND_ENUM_CONSTANT(FORMAT_RGTC_R); + BIND_ENUM_CONSTANT(FORMAT_RGTC_RG); + BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBA); //btpc bc6h + BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBF); //float / + BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBFU); //unsigned float + BIND_ENUM_CONSTANT(FORMAT_PVRTC2); //pvrtc + BIND_ENUM_CONSTANT(FORMAT_PVRTC2A); + BIND_ENUM_CONSTANT(FORMAT_PVRTC4); + BIND_ENUM_CONSTANT(FORMAT_PVRTC4A); + BIND_ENUM_CONSTANT(FORMAT_ETC); //etc1 + BIND_ENUM_CONSTANT(FORMAT_ETC2_R11); //etc2 + BIND_ENUM_CONSTANT(FORMAT_ETC2_R11S); //signed ); NOT srgb. + BIND_ENUM_CONSTANT(FORMAT_ETC2_RG11); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RG11S); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RGB8); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RGBA8); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RGB8A1); + BIND_ENUM_CONSTANT(FORMAT_MAX); + + BIND_ENUM_CONSTANT(INTERPOLATE_NEAREST); + BIND_ENUM_CONSTANT(INTERPOLATE_BILINEAR); + BIND_ENUM_CONSTANT(INTERPOLATE_CUBIC); + + BIND_ENUM_CONSTANT(ALPHA_NONE); + BIND_ENUM_CONSTANT(ALPHA_BIT); + BIND_ENUM_CONSTANT(ALPHA_BLEND); + + BIND_ENUM_CONSTANT(COMPRESS_S3TC); + BIND_ENUM_CONSTANT(COMPRESS_PVRTC2); + BIND_ENUM_CONSTANT(COMPRESS_PVRTC4); + BIND_ENUM_CONSTANT(COMPRESS_ETC); + BIND_ENUM_CONSTANT(COMPRESS_ETC2); + + BIND_ENUM_CONSTANT(COMPRESS_SOURCE_GENERIC); + BIND_ENUM_CONSTANT(COMPRESS_SOURCE_SRGB); + BIND_ENUM_CONSTANT(COMPRESS_SOURCE_NORMAL); } void Image::set_compress_bc_func(void (*p_compress_func)(Image *, CompressSource)) { |