C#

double earthC = 6371000 * 2 * Math.PI; double factor = Math.Pow(2, 8 + m_intZoomLevel); double MeterPerPixel = (Math.Cos(CenterLat * Math.PI / 180) * earthC / factor)/2; double MapWidthDistance = OrginalImageWidth * MeterPerPixel; double ActualMeterPerPixel = MapWidthDistance / imgWidthAfterResize;