How to calculate distance transfrom?
The output of the distance transform depends on the applied vector norm (euclidean, maximum, manhattan, ...), see e.g. here or here. 

From your example solution, I assume you take the Manhattan distance. Then, your result for the interior of the shape is correct. However, for the exterior of the region, why would it be zero? For the distance transform, the shape of the image does not count, it is only a pixel-based algorithm, where each pixel gets the value that matches its distance to the next non-zero pixel. Apply this to the outer pixels and you have the correct result.