How would I generate a two-dimensional texture of indexed colors to go with an exported palette?

I FINALLY FIGURED IT OUT.

By changing the R G and B value of each pixel to the corresponding index in the palette, the color gets indexed to the proper one. I don’t know if this is the right way to do palettes but it works so I’m not complaining.