blob: 8a5774fe887199847140711fc5aa8bd672a30444 [file] [log] [blame]
[email protected]69f5b1e62011-09-01 06:34:041// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]4ae30d082009-02-20 17:55:555#ifndef PRINTING_UNITS_H_
6#define PRINTING_UNITS_H_
initial.commit09911bf2008-07-26 23:55:297
[email protected]69f5b1e62011-09-01 06:34:048#include "printing/printing_export.h"
9
initial.commit09911bf2008-07-26 23:55:2910namespace printing {
11
[email protected]4c9054b2013-11-04 18:34:2912// Length of a thousandth of inches in 0.01mm unit.
initial.commit09911bf2008-07-26 23:55:2913const int kHundrethsMMPerInch = 2540;
14
Vladislav Kuzkokove2199102018-02-20 16:25:1315// Mil is a thousandth of an inch.
16constexpr float kMicronsPerMil = 25.4f;
17constexpr int kMilsPerInch = 1000;
18
[email protected]4ebf5d12010-06-28 09:46:0019// 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
21const 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
25const int kPixelsPerInch = 96;
26
[email protected]4c9054b2013-11-04 18:34:2927// Dpi used to save to PDF or Cloud Print.
28const int kDefaultPdfDpi = 300;
29
30// LETTER: 8.5 x 11 inches
31const float kLetterWidthInch = 8.5f;
32const float kLetterHeightInch = 11.0f;
33
34// LEGAL: 8.5 x 14 inches
35const float kLegalWidthInch = 8.5f;
36const float kLegalHeightInch = 14.0f;
37
38// A4: 8.27 x 11.69 inches
39const float kA4WidthInch = 8.27f;
40const float kA4HeightInch = 11.69f;
41
42// A3: 11.69 x 16.54 inches
43const float kA3WidthInch = 11.69f;
44const float kA3HeightInch = 16.54f;
45
initial.commit09911bf2008-07-26 23:55:2946// Converts from one unit system to another using integer arithmetics.
robhogan53c779c2016-08-03 06:34:5247PRINTING_EXPORT int ConvertUnit(double value, int old_unit, int new_unit);
initial.commit09911bf2008-07-26 23:55:2948
49// Converts from one unit system to another using doubles.
[email protected]69f5b1e62011-09-01 06:34:0450PRINTING_EXPORT double ConvertUnitDouble(double value, double old_unit,
51 double new_unit);
initial.commit09911bf2008-07-26 23:55:2952
53// Converts from 0.001 inch unit to 0.00001 meter.
[email protected]69f5b1e62011-09-01 06:34:0454PRINTING_EXPORT int ConvertMilliInchToHundredThousanthMeter(int milli_inch);
initial.commit09911bf2008-07-26 23:55:2955
56// Converts from 0.00001 meter unit to 0.001 inch.
[email protected]69f5b1e62011-09-01 06:34:0457PRINTING_EXPORT int ConvertHundredThousanthMeterToMilliInch(int cmm);
initial.commit09911bf2008-07-26 23:55:2958
[email protected]4ebf5d12010-06-28 09:46:0059// Converts from 1 pixel to 1 point using integers.
[email protected]69f5b1e62011-09-01 06:34:0460PRINTING_EXPORT int ConvertPixelsToPoint(int pixels);
[email protected]4ebf5d12010-06-28 09:46:0061
62// Converts from 1 pixel to 1 point using doubles.
[email protected]69f5b1e62011-09-01 06:34:0463PRINTING_EXPORT double ConvertPixelsToPointDouble(double pixels);
[email protected]4ebf5d12010-06-28 09:46:0064
[email protected]55b23a02011-08-17 23:09:3665// Converts from 1 point to 1 pixel using doubles.
[email protected]99d8a142014-07-18 22:18:0066PRINTING_EXPORT double ConvertPointsToPixelDouble(double points);
[email protected]55b23a02011-08-17 23:09:3667
initial.commit09911bf2008-07-26 23:55:2968} // namespace printing
69
[email protected]4ae30d082009-02-20 17:55:5570#endif // PRINTING_UNITS_H_