Set ruler at runtime

Anybody can tell me how to put ruler at runtime.
I want to use dat ruler for measuring the size of images.
Is it possible to do dat.
Please let me know how we can do dis.