Skip to content

Pixel color incorrect - appears cyan instead of white, possible red channel rendering issue #132

Closed as not planned
@San-tito

Description

@San-tito

When attempting to draw pixels on the screen using the provided pixel_put function, pixels intended to be white are instead rendered as cyan. This discrepancy suggests a potential problem with how the red channel is being handled during the rendering process.

static void pixel_put(mlx_image_t *image, int x, int y, int color)
{
    int i;
    unsigned char *pixel;

    if ((unsigned)x < (*image).width && (unsigned)y < (*image).height)
    {
        pixel = (*image).pixels + (y * (*image).width + x) * sizeof(int);
        i = sizeof(int) * 6;
        while (i >= 0)
        {
            *pixel++ = (color >> i) & 0xFF;
            i -= sizeof(int) * 2;
        }
    }
}

``
The pixel_put function is responsible for placing a pixel of a specified color at the given coordinates on an image. It operates by manipulating the pixel's color values, byte by byte, to set the appropriate RGB components.

This issue has been observed across multiple platforms, including Arch Linux and macOS Catalina. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working or should get fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions