Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

  1. #ifndef __eea5eb1f_2730_4617_a6e8_347ffd1068fa__
  2. #define __eea5eb1f_2730_4617_a6e8_347ffd1068fa__
  3. #include <windows.h>
  4. #include "simstr.h"
  5. namespace PrintScanUtil
  6. {
  7. inline int MulDivNoRound( int nNumber, int nNumerator, int nDenominator )
  8. {
  9. return(int)(((LONGLONG)nNumber * nNumerator) / nDenominator);
  10. }
  11. inline SIZE ScalePreserveAspectRatio( int nAvailX, int nAvailY, int nItemX, int nItemY )
  12. {
  13. SIZE sizeResult = { nAvailX, nAvailY };
  14. if (nItemX && nItemY)
  15. {
  16. //
  17. // Width is greater than height. X is the constraining factor
  18. //
  19. if (nAvailY*nItemX > nAvailX*nItemY)
  20. {
  21. sizeResult.cy = MulDivNoRound(nItemY,nAvailX,nItemX);
  22. }
  23. //
  24. // Height is greater than width. Y is the constraining factor
  25. //
  26. else
  27. {
  28. sizeResult.cx = MulDivNoRound(nItemX,nAvailY,nItemY);
  29. }
  30. }
  31. return sizeResult;
  32. }
  33. }
  34. #endif // __PSUTIL_H_INCLUDED