Skip to content

Explain how Image.set_pixel() works when the image format is not color #11399

@Yobbolita

Description

@Yobbolita

Your Godot version:

4.5

Issue description:

The Image.set_pixel() function has the following signature :

void set_pixel(x: int, y: int, color: Color)

However, the image format can be of different types, including types like L8 with only luminance and no colors.

In that case, the pixel contains a single int, not a color. What do you put as the color parameter of set_pixel() then ?

After testing, it appears that you can still set a pixel's value on a L8 image using set_pixel, the R value provided will be used as the luminance value, while G and B will be ignored. (that's what seems to be after light testing)

I think this deserve to be better explained in the docs, as it does seem like a set_pixel_luminance() function is missing if you don't know how this function works.

URL to the documentation page (if already existing):

https://docs.godotengine.org/en/stable/classes/class_image.html#class-image-method-set-pixel

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:class referenceIssues and PRs about the class reference, which should be addressed on the Godot engine repositoryenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions