Closed JezSonic closed 3 years ago
Could you try adding these lines of code to the fetch_callback
:
print(dimensions.height, ":", dimensions.width)
print(handle.size)
like so:
The likely issue is that the sdk is returning a square version of the image, but get_dimensions returns the original image dimensions.
Could you try adding these lines of code to the
fetch_callback
:print(dimensions.height, ":", dimensions.width) print(handle.size)
like so:
The likely issue is that the sdk is returning a square version of the image, but get_dimensions returns the original image dimensions.
sure, let me finish lessons and i'll do it
You have everything there, i also have updated issue
Ok, so it looks like the issue is that ImageDimensions
is the original image dimensions, but get_data
will return the resized image bytes to fit the size we passed to the ImageHandle
, so all we have to do is replace the fetch callback with this:
func fetch_callback(result: int, handle: Discord.ImageHandle) -> void:
if result != Discord.Result.OK:
print(
"Failed to fetch image handle: ",
enum_to_string(Discord.Result, result)
)
else:
print("Fetched image handle, ", handle.id, ", ", handle.size)
var data = images.get_data(handle)
if data is int:
print(
"Failed to get image data: ",
enum_to_string(Discord.Result, data)
)
else:
var image: = Image.new()
image.create_from_data(
handle.size, handle.size,
false,
Image.FORMAT_RGBA8,
data
)
image.unlock()
var tex: = ImageTexture.new()
tex.create_from_image(image)
texture_rect.texture = tex
OS.window_size = Vector2(handle.size, handle.size)
Let me know if it still doesnt work after replacing this function ^
I'm going to add something to the docs about this to prevent issues in future. Done:
:/
Could you try saving the resulting image to a png?
image.save_png("res://avatar.png")
there you have the result
Could you please send you whole main.gd file? I can't seem to replicate this issue myself, but I'll try using an alt account with smaller pfp later.
OK, I think I've figure out the issue, so I'm going to implement a fix now, let me know if it still doesn't work.
Ok, thanks
Could you please send you whole main.gd file? I can't seem to replicate this issue myself, but I'll try using an alt account with smaller pfp later.
I can't do it now... I'll do it as fast as possible.
Btw. If you prefer we can talk on discord, you have my nick and tag on the screen (Futrzak#7813)
Describe the bug
To Reproduce
Expected behaviour
Screenshots
Additional context
Please confirm the following: (Place an
X
between the square brackets)