diff options
Diffstat (limited to 'modules/etc')
-rw-r--r-- | modules/etc/image_etc.cpp | 21 | ||||
-rw-r--r-- | modules/etc/image_etc.h | 1 | ||||
-rw-r--r-- | modules/etc/register_types.cpp | 1 | ||||
-rw-r--r-- | modules/etc/register_types.h | 1 | ||||
-rw-r--r-- | modules/etc/texture_loader_pkm.cpp | 1 | ||||
-rw-r--r-- | modules/etc/texture_loader_pkm.h | 1 |
6 files changed, 25 insertions, 1 deletions
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index 2224ecc356..8a674bc8c1 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -27,6 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + #include "image_etc.h" #include "Etc.h" #include "EtcFilter.h" @@ -117,7 +118,6 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f } uint32_t imgw = p_img->get_width(), imgh = p_img->get_height(); - ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh); Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels); @@ -126,6 +126,25 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f if (img->get_format() != Image::FORMAT_RGBA8) img->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert + if (img->has_mipmaps()) { + if (next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh) { + img->resize_to_po2(); + imgw = img->get_width(); + imgh = img->get_height(); + } + } else { + if (imgw % 4 != 0 || imgh % 4 != 0) { + if (imgw % 4) { + imgw += 4 - imgw % 4; + } + if (imgh % 4) { + imgh += 4 - imgh % 4; + } + + img->resize(imgw, imgh); + } + } + PoolVector<uint8_t>::Read r = img->get_data().read(); int target_size = Image::get_image_data_size(imgw, imgh, etc_format, p_img->has_mipmaps() ? -1 : 0); diff --git a/modules/etc/image_etc.h b/modules/etc/image_etc.h index fb32a120b1..371c38176f 100644 --- a/modules/etc/image_etc.h +++ b/modules/etc/image_etc.h @@ -27,6 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + #ifndef IMAGE_ETC1_H #define IMAGE_ETC1_H diff --git a/modules/etc/register_types.cpp b/modules/etc/register_types.cpp index 42baf91dfa..1d1f0e1b77 100644 --- a/modules/etc/register_types.cpp +++ b/modules/etc/register_types.cpp @@ -27,6 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + #include "register_types.h" #include "image_etc.h" diff --git a/modules/etc/register_types.h b/modules/etc/register_types.h index 1f1336dc10..4a8513a687 100644 --- a/modules/etc/register_types.h +++ b/modules/etc/register_types.h @@ -27,5 +27,6 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + void register_etc_types(); void unregister_etc_types(); diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index 4f6df04341..ac89259c9b 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -27,6 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + #include "texture_loader_pkm.h" #include "os/file_access.h" diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h index 1e8833b547..3c6d9180bd 100644 --- a/modules/etc/texture_loader_pkm.h +++ b/modules/etc/texture_loader_pkm.h @@ -27,6 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + #ifndef TEXTURE_LOADER_PKM_H #define TEXTURE_LOADER_PKM_H |