blob: 0e19d043c83c7bf68f94cc66e78ffe2f8d765d56 [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
[email protected]4ebf5d12010-06-28 09:46:0015// 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
17const int kPointsPerInch = 72;
18
19// Length of an inch in CSS's 1px unit.
20// http://dev.w3.org/csswg/css3-values/#the-px-unit
21const int kPixelsPerInch = 96;
22
[email protected]4c9054b2013-11-04 18:34:2923// Dpi used to save to PDF or Cloud Print.
24const int kDefaultPdfDpi = 300;
25
26// LETTER: 8.5 x 11 inches
27const float kLetterWidthInch = 8.5f;
28const float kLetterHeightInch = 11.0f;
29
30// LEGAL: 8.5 x 14 inches
31const float kLegalWidthInch = 8.5f;
32const float kLegalHeightInch = 14.0f;
33
34// A4: 8.27 x 11.69 inches
35const float kA4WidthInch = 8.27f;
36const float kA4HeightInch = 11.69f;
37
38// A3: 11.69 x 16.54 inches
39const float kA3WidthInch = 11.69f;
40const float kA3HeightInch = 16.54f;
41
initial.commit09911bf2008-07-26 23:55:2942// Converts from one unit system to another using integer arithmetics.
robhogan53c779c2016-08-03 06:34:5243PRINTING_EXPORT int ConvertUnit(double value, int old_unit, int new_unit);
initial.commit09911bf2008-07-26 23:55:2944
45// Converts from one unit system to another using doubles.
[email protected]69f5b1e62011-09-01 06:34:0446PRINTING_EXPORT double ConvertUnitDouble(double value, double old_unit,
47 double new_unit);
initial.commit09911bf2008-07-26 23:55:2948
49// Converts from 0.001 inch unit to 0.00001 meter.
[email protected]69f5b1e62011-09-01 06:34:0450PRINTING_EXPORT int ConvertMilliInchToHundredThousanthMeter(int milli_inch);
initial.commit09911bf2008-07-26 23:55:2951
52// Converts from 0.00001 meter unit to 0.001 inch.
[email protected]69f5b1e62011-09-01 06:34:0453PRINTING_EXPORT int ConvertHundredThousanthMeterToMilliInch(int cmm);
initial.commit09911bf2008-07-26 23:55:2954
[email protected]4ebf5d12010-06-28 09:46:0055// Converts from 1 pixel to 1 point using integers.
[email protected]69f5b1e62011-09-01 06:34:0456PRINTING_EXPORT int ConvertPixelsToPoint(int pixels);
[email protected]4ebf5d12010-06-28 09:46:0057
58// Converts from 1 pixel to 1 point using doubles.
[email protected]69f5b1e62011-09-01 06:34:0459PRINTING_EXPORT double ConvertPixelsToPointDouble(double pixels);
[email protected]4ebf5d12010-06-28 09:46:0060
[email protected]55b23a02011-08-17 23:09:3661// Converts from 1 point to 1 pixel using doubles.
[email protected]99d8a142014-07-18 22:18:0062PRINTING_EXPORT double ConvertPointsToPixelDouble(double points);
[email protected]55b23a02011-08-17 23:09:3663
initial.commit09911bf2008-07-26 23:55:2964} // namespace printing
65
[email protected]4ae30d082009-02-20 17:55:5566#endif // PRINTING_UNITS_H_