• Hello again,

    I had some trouble generating a proper color value for g.setPixel. My current experiments have led to some weird results:

    • R,G,B parts have a range of 0...31
    • the color value may be composed as follows R << 11 | G << 6 | B

    But the shifts look strange - can they be correct?

  • That's correct (although G goes up to 63) - it's called 'RGB565' and is a standard way of packing RGB data into 16 bits.

    If you just want an easy solution use g.setColor though :)

  • Oh, that's interesting...I never heard of RGB565 before - but good to know.

    I need that conversion because of g.setPixel which expects a color value as its last argument.

  • I've just updated the docs, but it turns out that if you leave out the last argument it just defaults to using the foreground color so you can use setColor first if you need to.

    I guess there should really be a 'toColor` function to make the process easier

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

how to combine R,G,B values into a color value for setPixel

Posted by Avatar for Andreas_Rozek @Andreas_Rozek

Actions