| 1463 | } |
| 1464 | |
| 1465 | void fixLocation(IntRect* pLocation, int xRes, int yRes) |
| 1466 | { |
| 1467 | double resRatio = (double)xRes / yRes; |
| 1468 | |
| 1469 | double locationRatio = double(pLocation->uRight - pLocation->uLeft) / (pLocation->uTop - pLocation->uBottom); |
| 1470 | |
| 1471 | if (locationRatio > resRatio) |
| 1472 | { |
| 1473 | // location is wider. use height as reference. |
| 1474 | double width = (pLocation->uTop - pLocation->uBottom) * resRatio; |
| 1475 | pLocation->uLeft += (pLocation->uRight - pLocation->uLeft - width) / 2; |
| 1476 | pLocation->uRight = (pLocation->uLeft + width); |
| 1477 | } |
| 1478 | else if (locationRatio < resRatio) |
| 1479 | { |
| 1480 | // res is wider. use width as reference. |
| 1481 | double height = (pLocation->uRight - pLocation->uLeft) / resRatio; |
| 1482 | pLocation->uBottom += (pLocation->uTop - pLocation->uBottom - height) / 2; |
| 1483 | pLocation->uTop = (pLocation->uBottom + height); |
| 1484 | } |
| 1485 | } |
| 1486 | |
| 1487 | bool isPointInRect(IntPair point, IntRect* pRect) |
| 1488 | { |