Search code examples
crgbpixelnintendo-dslibnds

5 Bit RGB (0, 31, 0) to 16 Bit RGB (0, 255, 0)


So I've been starting DS programming, and I notice that to draw a pixel the color must be a RGB(0, 31, 0). Is there any way to change that to something like RGB(0, 255, 0)?


Solution

  • 5 bit rgb : 31 = 8 bit rgb : 255

    so 8 bit rgb = (5 bit rgb * 255 / 31)

    Example:

    5 bit RGB = 12,3,21
    
    8 bit R = (12 * 255) / 31 = 99
          G = (3 * 255) / 31  = 25
          B = (21 * 255) / 31 = 172
    

    PS: I think you mean "5 bit RGB to 8 bit RGB" in your title.