Display RGB values / P4_09

I'm trying to Display RGB values in a Color Cube like in Example P4_09, with the
difference that i already have the RGB Values in a 3 dimensional array.
(e.g [255,255,0] should map to yellow and should be displayed as 255,255,0).

I looked at also at the other examples, but couldn't find a good way to achieve

Thanks for any hint.