mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Fix bug where images with width or height 1 are unable to be exported/affected by image effects
For some reason, ShaderImageEffect does not like images with width/height of 1.
This commit is contained in:
parent
018f95158e
commit
97a1de6db2
|
@ -7,6 +7,16 @@ signal done
|
|||
|
||||
func generate_image(img: Image, shader: Shader, params: Dictionary, size: Vector2i) -> void:
|
||||
# duplicate shader before modifying code to avoid affecting original resource
|
||||
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
|
||||
shader = shader.duplicate()
|
||||
shader.code = shader.code.replace("unshaded", "unshaded, blend_premul_alpha")
|
||||
var vp := RenderingServer.viewport_create()
|
||||
|
@ -46,4 +56,8 @@ func generate_image(img: Image, shader: Shader, params: Dictionary, size: Vector
|
|||
RenderingServer.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)
|
||||
done.emit()
|
||||
|
|
Loading…
Reference in a new issue