In the books and movies, there is no known way to get out of the room once you're inside. The entrance is hidden behind a moving picture, and the only known way to get in is to solve the riddles that unlock the passage.
However, in the Harry Potter video games, the mechanics might be different. It's possible that in some games, you might be able to find a hidden lever, button, or other mechanism to open the room.
Can you clarify which specific game you're asking about? Knowing the game will help determine if there's a way to get out of the room.