diff options
Diffstat (limited to 'drivers/png/resource_saver_png.cpp')
-rw-r--r-- | drivers/png/resource_saver_png.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 89e8ee32cc..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(); @@ -79,7 +78,7 @@ bool ResourceSaverPNG::recognize(const RES &p_resource) const { void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (Object::cast_to<Texture>(*p_resource)) { + if (Object::cast_to<ImageTexture>(*p_resource)) { p_extensions->push_back("png"); } } |