Skip to content

Commit

Permalink
Fix bug where images with width or height 1 are being completely clea…
Browse files Browse the repository at this point in the history
…red by image effects
  • Loading branch information
OverloadedOrama committed Apr 9, 2024
1 parent 49b1403 commit fcfc606
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions src/Classes/ShaderImageEffect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")

0 comments on commit fcfc606

Please sign in to comment.