From fcfc606861d247856db5473b702628ebd71df43f Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 10 Apr 2024 02:21:43 +0300 Subject: [PATCH] Fix bug where images with width or height 1 are being completely cleared by image effects --- CHANGELOG.md | 1 + src/Classes/ShaderImageEffect.gd | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4543ae1e..aae60a13e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Built using Godot 3.5.2 - The same frames are no longer being exported multiple times when "Selected frames" is selected, and multiple cels of the same frames are currently selected on the timeline. [#1001](https://github.com/Orama-Interactive/Pixelorama/issues/1001) - Fixed crash due to division by zero when locking two or three ValueSliders, and one of them has the value of 0 and the user attempts to change it. - Fixed exporting selected layers not including the non-selected frames. +- Fix bug where images with width or height 1 are being completely cleared by image effects. - Made the color picker not select fully transparent pixels that are not black. [#999](https://github.com/Orama-Interactive/Pixelorama/issues/999) - The ellipse tool no longer produces gaps with large sizes. [4f3a7a305a264e0d2fe86c201af76eca4b2fea0a](https://github.com/Orama-Interactive/Pixelorama/commit/4f3a7a305a264e0d2fe86c201af76eca4b2fea0a) - Fix "visible layers" option on the export dialog producing wrong results. [346d1f071a8c6b1defb1072d39aea9c642f1ef59](https://github.com/Orama-Interactive/Pixelorama/commit/346d1f071a8c6b1defb1072d39aea9c642f1ef59) diff --git a/src/Classes/ShaderImageEffect.gd b/src/Classes/ShaderImageEffect.gd index 2746a545b..64a312acf 100644 --- a/src/Classes/ShaderImageEffect.gd +++ b/src/Classes/ShaderImageEffect.gd @@ -6,6 +6,16 @@ signal done func generate_image(img: Image, shader: Shader, params: Dictionary, size: Vector2) -> void: img.unlock() + var resized_width := false + var resized_height := false + if size.x == 1: + size.x = 2 + img.crop(2, img.get_height()) + resized_width = true + if size.y == 1: + size.y = 2 + img.crop(img.get_width(), 2) + resized_height = true # duplicate shader before modifying code to avoid affecting original resource shader = shader.duplicate() shader.code = shader.code.replace("unshaded", "unshaded, blend_premul_alpha") @@ -42,4 +52,8 @@ func generate_image(img: Image, shader: Shader, params: Dictionary, size: Vector VisualServer.free_rid(texture) viewport_texture.convert(Image.FORMAT_RGBA8) img.copy_from(viewport_texture) + if resized_width: + img.crop(img.get_width() - 1, img.get_height()) + if resized_height: + img.crop(img.get_width(), img.get_height() - 1) emit_signal("done")