The transponder is connected to the static system by either an encoding altimeter or a blind encoder. An encoding altimeter is an altimeter that has a plug on the back to link it to the transponder. The blind encoder resembles a beer can, but the new ones are smaller. It is usually mounted under the instrument panel or in the nose of a light twin. Both just tell the transponder what the aircraft's pressure altitude is. The do not send your indicated altitude for a very good reason. It would be easy for a pilot to incorrectly set the altimeter and for ATC or TCAS equipped aircraft to think your aircraft is at a different altitude than it actually is.
When set to squawk altitude, your transponder sends the beacon code and your pressure altitude to ATC whenever interrogated by the secondary radar system. (The primary radar will return a 'skin paint' off your aircraft but will not indicate altitude, it is the big antenna you see at an airport w/radar. The secondary radar is a smaller antenna mounted on top the primary antenna that interrogates your transponder.) The ATC radar has a computer that tells them what your actual altitude is, based on the altimeter setting the controllers enter into the system.
TCAS equipped aircraft and aircraft with an active TCAD will also interrogate your transponder. They can then determine your relative bearing and distance by using a directional antenna and measuring how long it takes the signal from your transponder to reach the interrogating aircraft.
Newer digital transponders from NARCO, Garmin and Bendix/King display your pressure altitude based on the input from the encoder in the aircraft.