I have an application in c that displayed image and allow to

I have an application in c# that displayed image and allow to zoom in and zoom out. I want to get the original pixel value from the original image. when I clicked with mouse at a point on the image(e.x,e.y) it should give this original pixel value not the value from displayed Bitmap. zoom in by adding 0.2 to the current zoom and zoom out by subtracting 0.2 from the current zoom. I did this by dividing current coordination(x,y) by the zoom factor, but sometimes it gives me the value of pixel off by one.

                double ratiox = ((mImage.mDisplayImage.Width * Zoom) / mImage.getW());
                double ratioy = ((mImage.mDisplayImage.Height * Zoom) / mImage.getH());
                int r = (int)(mMouseY / ratioy);
                int c = (int)(mMouseX / ratiox); mImage.GetPixel(r, c);

Is there any procedure that give the correct pixel value on the original image or should I changed the zoom factor( 0.2) to get better ratio ?!please help

Solution

}

I have an application in c# that displayed image and allow to zoom in and zoom out. I want to get the original pixel value from the original image. when I click

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site