why depth buffer save to image file can not display depth information

first i use glmatrixMode(GL_PROJECTION)
and gluOrtho()function to define the view volumn,glenable(GL_DEPTH_TEST),then I use glreadpixels() function to read depth information into depth buffers,and then convert it with the formula
depth = Znear+ (Zfar-Znear)*depthbuffer[i*Width+j];
to get the real depth, and then save it to a bitmap file with r,b,b have the same depth value,but when i look the image, it only display a blackcolor outline of my model,without depth information,but when i use gluperspective()to define the volumn,and use glCallList() to display the model and read its buffer,save it to file, it works correctly,I do not know why,how can i solve it?


depth = Znear+ (Zfar-Znear*depthbuffer[i*Width+j];

this isn’t the correct formula. Check out the back of the red book for the opengl projeciton matrix. You have to compute the inverse to the third row divided by the fourth row. I htink this is covered in this board, somewhere. (I vaguely rememebr speaking at lengths about it.)