save the current state to the device context