diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-02-06 00:38:39 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-02-06 00:38:39 -0300 |
commit | 6f2e16306a6552d704fb2346c9abdd26e0e523b7 (patch) | |
tree | e1fadf2a05d6f04675045b9e34128ed96628e07c /modules/etc1 | |
parent | af3fabeb7745e6f7f4e7fe7a299bdd234fff26a6 (diff) |
Several bugfixes, improving the import workflow
Diffstat (limited to 'modules/etc1')
-rw-r--r-- | modules/etc1/image_etc.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/modules/etc1/image_etc.cpp b/modules/etc1/image_etc.cpp index 36ff1b86df..2d883bff0f 100644 --- a/modules/etc1/image_etc.cpp +++ b/modules/etc1/image_etc.cpp @@ -95,7 +95,7 @@ static void _decompress_etc(Image *p_img) { //print_line("Re Creating ETC into regular image: w "+itos(p_img->get_width())+" h "+itos(p_img->get_height())+" mm "+itos(p_img->get_mipmaps())); *p_img=Image(p_img->get_width(),p_img->get_height(),p_img->has_mipmaps(),Image::FORMAT_RGB8,dst); if (p_img->has_mipmaps()) - p_img->generate_mipmaps(true); + p_img->generate_mipmaps(); } @@ -112,16 +112,17 @@ static void _compress_etc(Image *p_img) { img.convert(Image::FORMAT_RGB8); - int mmc=img.get_mipmap_count(); - if (mmc==0) - img.generate_mipmaps(); // force mipmaps, so it works on most hardware - - PoolVector<uint8_t> res_data; PoolVector<uint8_t> dst_data; PoolVector<uint8_t>::Read r = img.get_data().read(); + int target_size = Image::get_image_data_size(p_img->get_width(),p_img->get_height(),Image::FORMAT_ETC,p_img->has_mipmaps()?-1:0); + int mmc = p_img->has_mipmaps() ? Image::get_image_required_mipmaps(p_img->get_width(),p_img->get_height(),Image::FORMAT_ETC) : 0; + + dst_data.resize(target_size); int mc=0; + int ofs=0; + PoolVector<uint8_t>::Write w=dst_data.write(); rg_etc1::etc1_pack_params pp; @@ -133,9 +134,9 @@ static void _compress_etc(Image *p_img) { int bh=MAX(imgh/4,1); const uint8_t *src = &r[img.get_mipmap_offset(i)]; int mmsize = MAX(bw,1)*MAX(bh,1)*8; - dst_data.resize(dst_data.size()+mmsize); - PoolVector<uint8_t>::Write w=dst_data.write(); - uint8_t *dst = &w[dst_data.size()-mmsize]; + + uint8_t *dst = &w[ofs]; + ofs+=mmsize; //print_line("bh: "+itos(bh)+" bw: "+itos(bw)); |