Just change the bpp to 16 bits at the beginning of the program, and switching back to whatever bpp the user was running before at the end of the program.

Z.