Palettes are only used for 8-bit colour or less, for higher bitrates the colours are represented directly. You will either have to create the surface with an 8-bit palette, or manipulate the pixels individually (which will be very slow).