Skip to content

LibGDX drawPixel has Wrong Colours

January 17th, 2016 - Software(1 min)

TL;DR: Note that Pixmap.drawPixel(x, y, colour) expects a RGBA8888 colour, even if the pixmap is not RGBA8888.

Today I wanted to create a background with a bunch of different pixels and I had a lot of problems, displaying different colours from what I had in my array.

The process is simple: Pixmap > Texture > Sprite, with the colours being filled up in the pixmap using Pixmap.drawPixel(x, y, colour).

My Pixmap was created as RGB888, so I expected to draw the pixel with a RGB888 colour.

NO! you need RGBA888!


At the end of the day is not such a big deal, because all I needed to do was to change:

pix.drawPixel(i, 0, Color.rgb888(color.x, color.y, color.z));


pix.drawPixel(i, 0, Color.rgba8888(color.x, color.y, color.z, 1));


Share on

A little experiment: