diff options
author | Nils ANDRÉ-CHANG <nils@nilsand.re> | 2019-09-12 21:28:49 +0100 |
---|---|---|
committer | Nils ANDRÉ-CHANG <nils@nilsand.re> | 2019-09-26 20:36:12 +0100 |
commit | 0024dd7bb5a8a5194ed0283fc506edcd8b4a7737 (patch) | |
tree | 86316cccbf4fda58a275a7451e37fda83465bb20 /drivers/png | |
parent | cafb888361eba08297dd88b18dc71f4d418525c0 (diff) | |
parent | 24e1039eb6fe32115e8d1a62a84965e9be19a2ed (diff) |
Merge branch 'master' into tab_key
Diffstat (limited to 'drivers/png')
-rw-r--r-- | drivers/png/image_loader_png.h | 3 | ||||
-rw-r--r-- | drivers/png/png_driver_common.cpp | 9 | ||||
-rw-r--r-- | drivers/png/resource_saver_png.cpp | 9 |
3 files changed, 8 insertions, 13 deletions
diff --git a/drivers/png/image_loader_png.h b/drivers/png/image_loader_png.h index cc789f95d6..c910c31f1e 100644 --- a/drivers/png/image_loader_png.h +++ b/drivers/png/image_loader_png.h @@ -33,9 +33,6 @@ #include "core/io/image_loader.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ class ImageLoaderPNG : public ImageFormatLoader { private: static PoolVector<uint8_t> lossless_pack_png(const Ref<Image> &p_image); diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index 0e849bf2fe..7deac1d118 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -97,7 +97,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { break; default: png_image_free(&png_img); // only required when we return before finish_read - ERR_PRINT("Unsupported png format"); + ERR_PRINT("Unsupported png format."); return ERR_UNAVAILABLE; } @@ -179,10 +179,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) { ERR_FAIL_COND_V(check_error(png_img), FAILED); } if (!success) { - if (compressed_size <= png_size_estimate) { - // buffer was big enough, must be some other error - ERR_FAIL_V(FAILED); - } + + // buffer was big enough, must be some other error + ERR_FAIL_COND_V(compressed_size <= png_size_estimate, FAILED); // write failed due to buffer size, resize and retry Error err = p_buffer.resize(buffer_offset + compressed_size); diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 43a30f055b..3b3f1506dc 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -39,9 +39,8 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32 Ref<ImageTexture> texture = p_resource; - ERR_FAIL_COND_V(!texture.is_valid(), ERR_INVALID_PARAMETER); - ERR_EXPLAIN("Can't save empty texture as PNG"); - ERR_FAIL_COND_V(!texture->get_width() || !texture->get_height(), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V_MSG(!texture.is_valid(), ERR_INVALID_PARAMETER, "Can't save invalid texture as PNG."); + ERR_FAIL_COND_V_MSG(!texture->get_width(), ERR_INVALID_PARAMETER, "Can't save empty texture as PNG."); Ref<Image> img = texture->get_data(); @@ -54,9 +53,9 @@ Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img PoolVector<uint8_t> buffer; Error err = PNGDriverCommon::image_to_png(p_img, buffer); - ERR_FAIL_COND_V(err, err); + ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG."); FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err); - ERR_FAIL_COND_V(err, err); + ERR_FAIL_COND_V_MSG(err, err, vformat("Can't save PNG at path: '%s'.", p_path)); PoolVector<uint8_t>::Read reader = buffer.read(); |