diff options
| author | Jerome67000 | 2018-01-06 13:10:37 +0100 |
|---|---|---|
| committer | Jerome67000 | 2018-01-06 13:20:45 +0100 |
| commit | b5885c43eb479d1ea8beb71aac09b118a08cb855 (patch) | |
| tree | b9244fb6204a26e9a36525fb43eb4845de07d420 | |
| parent | 8e8240450edc48f4fb379e593a4ef7f54ab656b7 (diff) | |
| download | godot-b5885c43eb479d1ea8beb71aac09b118a08cb855.tar.gz godot-b5885c43eb479d1ea8beb71aac09b118a08cb855.tar.zst godot-b5885c43eb479d1ea8beb71aac09b118a08cb855.zip | |
| -rw-r--r-- | core/image.cpp | 7 | ||||
| -rw-r--r-- | doc/classes/Image.xml | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/core/image.cpp b/core/image.cpp index 59d66fd66..41d70e6df 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -447,8 +447,6 @@ void Image::convert(Format p_new_format) { Image new_img(width, height, 0, p_new_format); - //int len=data.size(); - PoolVector<uint8_t>::Read r = data.read(); PoolVector<uint8_t>::Write w = new_img.data.write(); @@ -696,6 +694,11 @@ void Image::resize_to_po2(bool p_square) { void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { + if (data.size() == 0) { + ERR_EXPLAIN("Cannot resize image before creating it, use create() or create_from_data() first."); + ERR_FAIL(); + } + if (!_can_modify(format)) { ERR_EXPLAIN("Cannot resize in indexed, compressed or custom image formats."); ERR_FAIL(); diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index a01ffc99b..80bef2b38 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -395,6 +395,7 @@ Sets the [Color] of the pixel at [code](x, y)[/code] if the image is locked. Example: [codeblock] var img = Image.new() + img.create(img_width, img_height, false, Image.FORMAT_RGBA8) img.lock() img.set_pixel(x, y, color) # Works img.unlock() |
