[go: nahoru, domu]

blob: fc7823697af3a0ce9a1cc4de3d9dd03bb1c87012 [file] [log] [blame]
darin@chromium.org69f5b1e62011-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
maruel@chromium.org4ae30d082009-02-20 17:55:555#ifndef PRINTING_UNITS_H_
6#define PRINTING_UNITS_H_
initial.commit09911bf2008-07-26 23:55:297
Alan Screen9347cae2021-04-27 18:11:248#include "base/component_export.h"
darin@chromium.org69f5b1e62011-09-01 06:34:049
initial.commit09911bf2008-07-26 23:55:2910namespace printing {
11
Lei Zhangd11ab162018-06-26 04:28:5012// Length of an inch in 0.001mm unit.
13constexpr int kMicronsPerInch = 25400;
initial.commit09911bf2008-07-26 23:55:2914
Vladislav Kuzkokove2199102018-02-20 16:25:1315// Mil is a thousandth of an inch.
16constexpr float kMicronsPerMil = 25.4f;
17constexpr int kMilsPerInch = 1000;
18
hamaji@chromium.org4ebf5d12010-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
Daniel Hosseiniand8f4bc72019-12-16 20:13:1721constexpr int kPointsPerInch = 72;
hamaji@chromium.org4ebf5d12010-06-28 09:46:0022
23// Length of an inch in CSS's 1px unit.
24// http://dev.w3.org/csswg/css3-values/#the-px-unit
Daniel Hosseiniand8f4bc72019-12-16 20:13:1725constexpr int kPixelsPerInch = 96;
hamaji@chromium.org4ebf5d12010-06-28 09:46:0026
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2927// Dpi used to save to PDF or Cloud Print.
Daniel Hosseiniand8f4bc72019-12-16 20:13:1728constexpr int kDefaultPdfDpi = 300;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2929
30// LETTER: 8.5 x 11 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1731constexpr float kLetterWidthInch = 8.5f;
32constexpr float kLetterHeightInch = 11.0f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2933
34// LEGAL: 8.5 x 14 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1735constexpr float kLegalWidthInch = 8.5f;
36constexpr float kLegalHeightInch = 14.0f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2937
38// A4: 8.27 x 11.69 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1739constexpr float kA4WidthInch = 8.27f;
40constexpr float kA4HeightInch = 11.69f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2941
42// A3: 11.69 x 16.54 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1743constexpr float kA3WidthInch = 11.69f;
44constexpr float kA3HeightInch = 16.54f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2945
initial.commit09911bf2008-07-26 23:55:2946// Converts from one unit system to another using integer arithmetics.
Alan Screen9347cae2021-04-27 18:11:2447COMPONENT_EXPORT(PRINTING)
48int ConvertUnit(double value, int old_unit, int new_unit);
initial.commit09911bf2008-07-26 23:55:2949
50// Converts from one unit system to another using doubles.
Alan Screen9347cae2021-04-27 18:11:2451COMPONENT_EXPORT(PRINTING)
52double ConvertUnitDouble(double value, double old_unit, double new_unit);
initial.commit09911bf2008-07-26 23:55:2953
hamaji@chromium.org4ebf5d12010-06-28 09:46:0054// Converts from 1 pixel to 1 point using integers.
Alan Screen9347cae2021-04-27 18:11:2455COMPONENT_EXPORT(PRINTING) int ConvertPixelsToPoint(int pixels);
hamaji@chromium.org4ebf5d12010-06-28 09:46:0056
57// Converts from 1 pixel to 1 point using doubles.
Alan Screen9347cae2021-04-27 18:11:2458COMPONENT_EXPORT(PRINTING) double ConvertPixelsToPointDouble(double pixels);
hamaji@chromium.org4ebf5d12010-06-28 09:46:0059
aayushkumar@chromium.org55b23a02011-08-17 23:09:3660// Converts from 1 point to 1 pixel using doubles.
Alan Screen9347cae2021-04-27 18:11:2461COMPONENT_EXPORT(PRINTING) double ConvertPointsToPixelDouble(double points);
aayushkumar@chromium.org55b23a02011-08-17 23:09:3662
initial.commit09911bf2008-07-26 23:55:2963} // namespace printing
64
maruel@chromium.org4ae30d082009-02-20 17:55:5565#endif // PRINTING_UNITS_H_