Using OPENCV to show an image (jpg etc)

Using OPENGL to draw on this image. Specifically drawing trace lines around the edges of the drawing.

When i scroll left/right and up/down my OpenGL draws offset.

Im not sure how to get these to align without hard coding.

I hard coded some numbers that eventually work so when I use the scroll bars everything lines up. However, i am having to use differnt numbers for differnt computers. To make matters worse, when i remote destop i noticed my image is scretched about 5% in the X axis. This means, a 10 x 10 box will draw about 10.5 x 10 but only remote desktop. Without Remote Desktop the same PC i remote into does not have the 5% issues but, i am still having to hard code the numbers in to work.


So in short, i need to find out how to calculate the following numbers that i had to hard code.

m_image = cvLoadImage(pDoc->m_sImageFilePath)

if(true)///Work PC screen
{
xPixels = .2825; ///(???)
yPixels = xPixels;
}
else if(false)//Remote Desktop screen
{
xPixels = .4;
yPixels = .3336;
}

GLfloat x = (-m_image->width / 2) - (pDoc->m_pWindowOrg.x) * xPixels;
GLfloat y = (m_image->height / 2) - (pDoc->m_pWindowOrg.y) * yPixels;

glRasterPos2f(pDoc->m_pWindowOrg.x,pDoc->m_pWindowOrg.y);

glBitmap(NULL,NULL,m_image->width,m_image->height,pDoc->m_fZoomScale * x,pDoc->m_fZoomScale * y,NULL);