Compression ratio measures compression as cylinder volume at BDC divided by cylinder volume at TDC. It is stated as a ratio in terms of X:1, where "X" is the quotient of volume at BDC divided by volume at TDC. This is a theoretical measurement used in designing an engine, it assumes optimal conditions and it does not reflect engine condition.
To find the cylinder volume at TDC, see Measuring combustion chamber volume.
To find the cylinder volume at BDC, add the cylinder's swept area [(pi/4)*diameter^2*stroke] to the volume at TDC.