[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 4ae30d08 | 2009-02-20 17:55:55 | [diff] [blame] | 5 | #ifndef PRINTING_UNITS_H_ |
6 | #define PRINTING_UNITS_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 8 | #include "printing/printing_export.h" |
9 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 10 | namespace printing { |
11 | |||||
[email protected] | 4c9054b | 2013-11-04 18:34:29 | [diff] [blame] | 12 | // Length of a thousandth of inches in 0.01mm unit. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | const int kHundrethsMMPerInch = 2540; |
14 | |||||
Vladislav Kuzkokov | e219910 | 2018-02-20 16:25:13 | [diff] [blame] | 15 | // Mil is a thousandth of an inch. |
16 | constexpr float kMicronsPerMil = 25.4f; | ||||
17 | constexpr int kMilsPerInch = 1000; | ||||
18 | |||||
[email protected] | 4ebf5d1 | 2010-06-28 09:46:00 | [diff] [blame] | 19 | // Length of an inch in CSS's 1pt unit. |
20 | // http://dev.w3.org/csswg/css3-values/#absolute-length-units-cm-mm.-in-pt-pc | ||||
21 | const int kPointsPerInch = 72; | ||||
22 | |||||
23 | // Length of an inch in CSS's 1px unit. | ||||
24 | // http://dev.w3.org/csswg/css3-values/#the-px-unit | ||||
25 | const int kPixelsPerInch = 96; | ||||
26 | |||||
[email protected] | 4c9054b | 2013-11-04 18:34:29 | [diff] [blame] | 27 | // Dpi used to save to PDF or Cloud Print. |
28 | const int kDefaultPdfDpi = 300; | ||||
29 | |||||
30 | // LETTER: 8.5 x 11 inches | ||||
31 | const float kLetterWidthInch = 8.5f; | ||||
32 | const float kLetterHeightInch = 11.0f; | ||||
33 | |||||
34 | // LEGAL: 8.5 x 14 inches | ||||
35 | const float kLegalWidthInch = 8.5f; | ||||
36 | const float kLegalHeightInch = 14.0f; | ||||
37 | |||||
38 | // A4: 8.27 x 11.69 inches | ||||
39 | const float kA4WidthInch = 8.27f; | ||||
40 | const float kA4HeightInch = 11.69f; | ||||
41 | |||||
42 | // A3: 11.69 x 16.54 inches | ||||
43 | const float kA3WidthInch = 11.69f; | ||||
44 | const float kA3HeightInch = 16.54f; | ||||
45 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 46 | // Converts from one unit system to another using integer arithmetics. |
robhogan | 53c779c | 2016-08-03 06:34:52 | [diff] [blame] | 47 | PRINTING_EXPORT int ConvertUnit(double value, int old_unit, int new_unit); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 48 | |
49 | // Converts from one unit system to another using doubles. | ||||
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 50 | PRINTING_EXPORT double ConvertUnitDouble(double value, double old_unit, |
51 | double new_unit); | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 52 | |
53 | // Converts from 0.001 inch unit to 0.00001 meter. | ||||
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 54 | PRINTING_EXPORT int ConvertMilliInchToHundredThousanthMeter(int milli_inch); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 55 | |
56 | // Converts from 0.00001 meter unit to 0.001 inch. | ||||
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 57 | PRINTING_EXPORT int ConvertHundredThousanthMeterToMilliInch(int cmm); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 58 | |
[email protected] | 4ebf5d1 | 2010-06-28 09:46:00 | [diff] [blame] | 59 | // Converts from 1 pixel to 1 point using integers. |
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 60 | PRINTING_EXPORT int ConvertPixelsToPoint(int pixels); |
[email protected] | 4ebf5d1 | 2010-06-28 09:46:00 | [diff] [blame] | 61 | |
62 | // Converts from 1 pixel to 1 point using doubles. | ||||
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 63 | PRINTING_EXPORT double ConvertPixelsToPointDouble(double pixels); |
[email protected] | 4ebf5d1 | 2010-06-28 09:46:00 | [diff] [blame] | 64 | |
[email protected] | 55b23a0 | 2011-08-17 23:09:36 | [diff] [blame] | 65 | // Converts from 1 point to 1 pixel using doubles. |
[email protected] | 99d8a14 | 2014-07-18 22:18:00 | [diff] [blame] | 66 | PRINTING_EXPORT double ConvertPointsToPixelDouble(double points); |
[email protected] | 55b23a0 | 2011-08-17 23:09:36 | [diff] [blame] | 67 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 68 | } // namespace printing |
69 | |||||
[email protected] | 4ae30d08 | 2009-02-20 17:55:55 | [diff] [blame] | 70 | #endif // PRINTING_UNITS_H_ |