units.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PRINTING_UNITS_H_
  5. #define PRINTING_UNITS_H_
  6. #include "base/component_export.h"
  7. namespace printing {
  8. // Length of an inch in 0.001mm unit.
  9. constexpr int kMicronsPerInch = 25400;
  10. // Mil is a thousandth of an inch.
  11. constexpr float kMicronsPerMil = 25.4f;
  12. constexpr int kMilsPerInch = 1000;
  13. // Length of an inch in CSS's 1pt unit.
  14. // http://dev.w3.org/csswg/css3-values/#absolute-length-units-cm-mm.-in-pt-pc
  15. constexpr int kPointsPerInch = 72;
  16. // Length of an inch in CSS's 1px unit.
  17. // http://dev.w3.org/csswg/css3-values/#the-px-unit
  18. constexpr int kPixelsPerInch = 96;
  19. // Dpi used to save to PDF or Cloud Print.
  20. constexpr int kDefaultPdfDpi = 300;
  21. // LETTER: 8.5 x 11 inches
  22. constexpr float kLetterWidthInch = 8.5f;
  23. constexpr float kLetterHeightInch = 11.0f;
  24. // LEGAL: 8.5 x 14 inches
  25. constexpr float kLegalWidthInch = 8.5f;
  26. constexpr float kLegalHeightInch = 14.0f;
  27. // A4: 8.27 x 11.69 inches
  28. constexpr float kA4WidthInch = 8.27f;
  29. constexpr float kA4HeightInch = 11.69f;
  30. // A3: 11.69 x 16.54 inches
  31. constexpr float kA3WidthInch = 11.69f;
  32. constexpr float kA3HeightInch = 16.54f;
  33. // Converts from one unit system to another using integer arithmetics.
  34. COMPONENT_EXPORT(PRINTING_BASE)
  35. int ConvertUnit(float value, int old_unit, int new_unit);
  36. // Converts from one unit system to another using floats.
  37. COMPONENT_EXPORT(PRINTING_BASE)
  38. float ConvertUnitFloat(float value, float old_unit, float new_unit);
  39. } // namespace printing
  40. #endif // PRINTING_UNITS_H_