YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

RGB values switched with separated colour_get_* vs getpixel #7979

Open gm-bug-reporter[bot] opened 3 weeks ago

gm-bug-reporter[bot] commented 3 weeks ago

Description

When I analyze a pixel, it manages to return the RGB correctly, as shown in the image. However, the decimal value is incorrect. In the case of the red color it returns the Decimal of the Blue color and in the case of the blue color it returns the Decimal of the red color. Only the green color is correct.

Steps To Reproduce

//Create a sprite where a color is placed (1x1 sprite). //Then use this code to read the pixel.

var surface = surface_create(1, 1);

surface_set_target(surface); draw_sprite(sprite, 0, 0, 0); surface_reset_target();

var pixel = surface_getpixel(surface,0,0)

//Then take the colors, red, green and blue of the chosen color.

var r = color_get_red(pixel) var g = color_get_green(pixel) var b = color_get_blue(pixel)

//Finally, draw a text with the decimal value, then the red value, then the green and finally the blue

draw_text(10, 10, "Decimal = "+ string(pixel) + " RGB = "+ string(r) + ", " + string(g) + ", " + string(b)); }

surface_free(surface);

Which version of GameMaker are you reporting this issue for?

IDE v2024.8.1.171 Runtime v2024.8.1.218

Which operating system(s) are you seeing the problem on?

Windows 10.0.22631.0

Attached Files

7e26af10-3a88-465b-a1a3-9c3e4b1a9751

alicemoretti commented 3 weeks ago

Reproduced on IDE v2024.1100.0.645 Beta Runtime v2024.1100.0.658 . This also affects draw_getpixel(). I've expanded the project with an example for that here: https://api.gamemaker.io/api/github/downloads/bc27c4ec-2623-4e1e-b613-c14b8cee27a2

rwkay commented 3 weeks ago

This function reads the hardware buffer for the colour - it is not always stored in the same format, depends on the hardware manufacturer.