OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PRINTING_UNITS_H_ | 5 #ifndef PRINTING_UNITS_H_ |
6 #define PRINTING_UNITS_H_ | 6 #define PRINTING_UNITS_H_ |
7 | 7 |
8 #include "printing/printing_export.h" | 8 #include "printing/printing_export.h" |
9 | 9 |
10 namespace printing { | 10 namespace printing { |
11 | 11 |
12 // Length of a thousanth of inches in 0.01mm unit. | 12 // Length of a thousandth of inches in 0.01mm unit. |
13 const int kHundrethsMMPerInch = 2540; | 13 const int kHundrethsMMPerInch = 2540; |
14 | 14 |
15 // Length of an inch in CSS's 1pt unit. | 15 // Length of an inch in CSS's 1pt unit. |
16 // http://dev.w3.org/csswg/css3-values/#absolute-length-units-cm-mm.-in-pt-pc | 16 // http://dev.w3.org/csswg/css3-values/#absolute-length-units-cm-mm.-in-pt-pc |
17 const int kPointsPerInch = 72; | 17 const int kPointsPerInch = 72; |
18 | 18 |
19 // Length of an inch in CSS's 1px unit. | 19 // Length of an inch in CSS's 1px unit. |
20 // http://dev.w3.org/csswg/css3-values/#the-px-unit | 20 // http://dev.w3.org/csswg/css3-values/#the-px-unit |
21 const int kPixelsPerInch = 96; | 21 const int kPixelsPerInch = 96; |
22 | 22 |
| 23 // Dpi used to save to PDF or Cloud Print. |
| 24 const int kDefaultPdfDpi = 300; |
| 25 |
| 26 // LETTER: 8.5 x 11 inches |
| 27 const float kLetterWidthInch = 8.5f; |
| 28 const float kLetterHeightInch = 11.0f; |
| 29 |
| 30 // LEGAL: 8.5 x 14 inches |
| 31 const float kLegalWidthInch = 8.5f; |
| 32 const float kLegalHeightInch = 14.0f; |
| 33 |
| 34 // A4: 8.27 x 11.69 inches |
| 35 const float kA4WidthInch = 8.27f; |
| 36 const float kA4HeightInch = 11.69f; |
| 37 |
| 38 // A3: 11.69 x 16.54 inches |
| 39 const float kA3WidthInch = 11.69f; |
| 40 const float kA3HeightInch = 16.54f; |
| 41 |
23 // Converts from one unit system to another using integer arithmetics. | 42 // Converts from one unit system to another using integer arithmetics. |
24 PRINTING_EXPORT int ConvertUnit(int value, int old_unit, int new_unit); | 43 PRINTING_EXPORT int ConvertUnit(int value, int old_unit, int new_unit); |
25 | 44 |
26 // Converts from one unit system to another using doubles. | 45 // Converts from one unit system to another using doubles. |
27 PRINTING_EXPORT double ConvertUnitDouble(double value, double old_unit, | 46 PRINTING_EXPORT double ConvertUnitDouble(double value, double old_unit, |
28 double new_unit); | 47 double new_unit); |
29 | 48 |
30 // Converts from 0.001 inch unit to 0.00001 meter. | 49 // Converts from 0.001 inch unit to 0.00001 meter. |
31 PRINTING_EXPORT int ConvertMilliInchToHundredThousanthMeter(int milli_inch); | 50 PRINTING_EXPORT int ConvertMilliInchToHundredThousanthMeter(int milli_inch); |
32 | 51 |
33 // Converts from 0.00001 meter unit to 0.001 inch. | 52 // Converts from 0.00001 meter unit to 0.001 inch. |
34 PRINTING_EXPORT int ConvertHundredThousanthMeterToMilliInch(int cmm); | 53 PRINTING_EXPORT int ConvertHundredThousanthMeterToMilliInch(int cmm); |
35 | 54 |
36 // Converts from 1 pixel to 1 point using integers. | 55 // Converts from 1 pixel to 1 point using integers. |
37 PRINTING_EXPORT int ConvertPixelsToPoint(int pixels); | 56 PRINTING_EXPORT int ConvertPixelsToPoint(int pixels); |
38 | 57 |
39 // Converts from 1 pixel to 1 point using doubles. | 58 // Converts from 1 pixel to 1 point using doubles. |
40 PRINTING_EXPORT double ConvertPixelsToPointDouble(double pixels); | 59 PRINTING_EXPORT double ConvertPixelsToPointDouble(double pixels); |
41 | 60 |
42 // Converts from 1 point to 1 pixel using doubles. | 61 // Converts from 1 point to 1 pixel using doubles. |
43 double ConvertPointsToPixelDouble(double points); | 62 double ConvertPointsToPixelDouble(double points); |
44 | 63 |
45 } // namespace printing | 64 } // namespace printing |
46 | 65 |
47 #endif // PRINTING_UNITS_H_ | 66 #endif // PRINTING_UNITS_H_ |
OLD | NEW |