summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-02-06 00:38:39 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-02-06 00:38:39 -0300
commit6f2e16306a6552d704fb2346c9abdd26e0e523b7 (patch)
treee1fadf2a05d6f04675045b9e34128ed96628e07c /modules
parentaf3fabeb7745e6f7f4e7fe7a299bdd234fff26a6 (diff)
Several bugfixes, improving the import workflow
Diffstat (limited to 'modules')
-rw-r--r--modules/etc1/image_etc.cpp19
-rw-r--r--modules/squish/image_compress_squish.cpp5
2 files changed, 12 insertions, 12 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));
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index a48c1f3485..28c200596b 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -64,10 +64,9 @@ void image_compress_squish(Image *p_image) {
p_image->convert(Image::FORMAT_RGBA8); //always expects rgba
- int mm_count = p_image->get_mipmap_count();
-
PoolVector<uint8_t> data;
- int target_size = Image::get_image_data_size(w,h,target_format,mm_count);
+ int target_size = Image::get_image_data_size(w,h,target_format,p_image->has_mipmaps()?-1:0);
+ int mm_count = p_image->has_mipmaps() ? Image::get_image_required_mipmaps(w,h,target_format) : 0;
data.resize(target_size);
PoolVector<uint8_t>::Read rb = p_image->get_data().read();