how to calculate coordinates of rect by image dimension

if i have an image 123x256 pixels
if i draw a rect that have the same size as this image,how can i calculate the coordinates of vertices of this rect by modelview,projectio,viewport and image dimensions!

Do you want the image to cover the whole viewport?

Assuming your window size is width and height, setup the viewport
glViewport(0, 0, width, height);

setup your ortho projection to match the viewport
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, width, 0.0, height, -1.0, 1.0);

You can leave the modelview as is
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

and render your quad
glColor4f(1.0, 1.0, 1.0, 1.0);
glBegin(GL_QUADS);
glVertex2f(0.0, 0.0);
glVertex2f(123.0, 0.0);
glVertex2f(123.0, 256.0);
glVertex2f(0.0, 256.0);
glEnd();

No,i want the image cover my rect,and it’s not distorted

[QUOTE=V-man;1241557]Assuming your window size is width and height, setup the viewport
glViewport(0, 0, width, height);

setup your ortho projection to match the viewport
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, width, 0.0, height, -1.0, 1.0);

You can leave the modelview as is
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

and render your quad
glColor4f(1.0, 1.0, 1.0, 1.0);
glBegin(GL_QUADS);
glVertex2f(0.0, 0.0);
glVertex2f(123.0, 0.0);
glVertex2f(123.0, 256.0);
glVertex2f(0.0, 256.0);
glEnd();[/QUOTE]

Can this method achieve?

Is there anybody can help me out?

Do you know how to render a texture (image) to a quad?

Yes,i know this,but how to make the image not magnify and shrink

If you transform the quad the image is mapped to using a perspective projection or an ortho projection with certain parameters there is no way you can keep it the same size on the screen. The image will theoretically still cover the whole quad but the quad itself will cover less pixel after projection.

What exactly is your goal here? Do you want the image to always cover the an area equal to the image dimensions? Do you want somethng like a HUD?