/src/libreoffice/include/vcl/canvastools.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_VCL_CANVASTOOLS_HXX |
21 | | #define INCLUDED_VCL_CANVASTOOLS_HXX |
22 | | |
23 | | #include <basegfx/numeric/ftools.hxx> |
24 | | #include <basegfx/range/b2irectangle.hxx> |
25 | | |
26 | | #include <vcl/dllapi.h> |
27 | | |
28 | | class Point; |
29 | | class Size; |
30 | | namespace tools { class Rectangle; } |
31 | | class Bitmap; |
32 | | class Color; |
33 | | |
34 | | namespace basegfx |
35 | | { |
36 | | class B2DVector; |
37 | | class B2DPoint; |
38 | | class B2DRange; |
39 | | class B2IPoint; |
40 | | class B2IRange; |
41 | | class B2DSize; |
42 | | } |
43 | | |
44 | | namespace com::sun::star::geometry |
45 | | { |
46 | | struct RealSize2D; |
47 | | struct IntegerPoint2D; |
48 | | struct IntegerSize2D; |
49 | | struct IntegerRectangle2D; |
50 | | } |
51 | | |
52 | | namespace com::sun::star::rendering |
53 | | { |
54 | | class XBitmap; |
55 | | class XIntegerReadOnlyBitmap; |
56 | | } |
57 | | |
58 | | namespace com::sun::star::rendering { class XColorSpace; } |
59 | | namespace com::sun::star::uno { template <class E> class Sequence; } |
60 | | namespace com::sun::star::uno { template <class interface_type> class Reference; } |
61 | | |
62 | | namespace vcl::unotools |
63 | | { |
64 | | // Bitmap conversions |
65 | | |
66 | | |
67 | | /** Create an XBitmap from VCL Bitmap( |
68 | | */ |
69 | | css::uno::Reference< css::rendering::XBitmap > |
70 | | VCL_DLLPUBLIC xBitmapFromBitmap( const ::Bitmap& inputBitmap ); |
71 | | |
72 | | /** Create a Bitmap from an XBitmap |
73 | | */ |
74 | | ::Bitmap VCL_DLLPUBLIC bitmapFromXBitmap( const css::uno::Reference< css::rendering::XIntegerReadOnlyBitmap >& xInputBitmap ); |
75 | | |
76 | | // Color conversions (vcl/tools Color <-> canvas standard color space) |
77 | | |
78 | | |
79 | | /** Create a device-specific color sequence from VCL/Tools color |
80 | | |
81 | | Note that this method assumes a color space equivalent to |
82 | | the one returned from createStandardColorSpace() |
83 | | */ |
84 | | css::uno::Sequence< double > |
85 | | VCL_DLLPUBLIC colorToStdColorSpaceSequence( const Color& rColor ); |
86 | | |
87 | | /** Convert color to device color sequence |
88 | | |
89 | | @param rColor |
90 | | Color to convert |
91 | | |
92 | | @param xColorSpace |
93 | | Color space to convert into |
94 | | */ |
95 | | css::uno::Sequence< double > |
96 | | VCL_DLLPUBLIC colorToDoubleSequence( const Color& rColor, |
97 | | const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace ); |
98 | | |
99 | | /** Convert from standard device color space to VCL/Tools color |
100 | | |
101 | | Note that this method assumes a color space equivalent to |
102 | | the one returned from createStandardColorSpace() |
103 | | */ |
104 | | Color VCL_DLLPUBLIC stdColorSpaceSequenceToColor( |
105 | | const css::uno::Sequence< double >& rColor ); |
106 | | |
107 | | /** Convert color to device color sequence |
108 | | |
109 | | @param rColor |
110 | | Color sequence to convert from |
111 | | |
112 | | @param xColorSpace |
113 | | Color space to convert from |
114 | | */ |
115 | | Color VCL_DLLPUBLIC doubleSequenceToColor( const css::uno::Sequence< double >& rColor, |
116 | | const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace ); |
117 | | |
118 | | /// Convert [0,1] double value to [0,255] int |
119 | | inline sal_Int8 toByteColor( double val ) |
120 | 0 | { |
121 | 0 | return sal::static_int_cast<sal_Int8>( |
122 | 0 | basegfx::fround(val*255.0)); |
123 | 0 | } |
124 | | |
125 | | /// Convert [0,255] int value to [0,1] double value |
126 | | inline double toDoubleColor( sal_uInt8 val ) |
127 | 0 | { |
128 | 0 | return val / 255.0; |
129 | 0 | } |
130 | | |
131 | | /// Create a standard color space suitable for VCL RGB color |
132 | | css::uno::Reference< css::rendering::XColorSpace> VCL_DLLPUBLIC createStandardColorSpace(); |
133 | | |
134 | | // Geometry conversions (vcl/tools <-> x) |
135 | | |
136 | | |
137 | | // geometry::Real |
138 | | css::geometry::RealSize2D VCL_DLLPUBLIC size2DFromSize( const Size& ); |
139 | | |
140 | | Size VCL_DLLPUBLIC sizeFromRealSize2D( const css::geometry::RealSize2D& ); |
141 | | |
142 | | // geometry::Integer |
143 | | css::geometry::IntegerSize2D VCL_DLLPUBLIC integerSize2DFromSize( const Size& ); |
144 | | |
145 | | Size VCL_DLLPUBLIC sizeFromIntegerSize2D( const css::geometry::IntegerSize2D& ); |
146 | | Point VCL_DLLPUBLIC pointFromIntegerPoint2D( const css::geometry::IntegerPoint2D& ); |
147 | | tools::Rectangle VCL_DLLPUBLIC rectangleFromIntegerRectangle2D( const css::geometry::IntegerRectangle2D& ); |
148 | | |
149 | | // basegfx::B2D |
150 | | Size VCL_DLLPUBLIC sizeFromB2DSize( const basegfx::B2DVector& ); |
151 | | Point VCL_DLLPUBLIC pointFromB2DPoint( const basegfx::B2DPoint& ); |
152 | | tools::Rectangle VCL_DLLPUBLIC rectangleFromB2DRectangle( const basegfx::B2DRange& ); |
153 | | |
154 | | VCL_DLLPUBLIC basegfx::B2DSize b2DSizeFromSize(const Size& rSize); |
155 | | VCL_DLLPUBLIC basegfx::B2DVector b2DVectorFromSize(const Size& rSize); |
156 | | basegfx::B2DPoint VCL_DLLPUBLIC b2DPointFromPoint( const Point& ); |
157 | | basegfx::B2DRange VCL_DLLPUBLIC b2DRectangleFromRectangle( const tools::Rectangle& ); |
158 | | |
159 | | // basegfx::B2I |
160 | | Point VCL_DLLPUBLIC pointFromB2IPoint( const basegfx::B2IPoint& ); |
161 | | tools::Rectangle VCL_DLLPUBLIC rectangleFromB2IRectangle( const basegfx::B2IRange& ); |
162 | | basegfx::B2IPoint VCL_DLLPUBLIC b2IPointFromPoint(const Point&); |
163 | | basegfx::B2IRectangle VCL_DLLPUBLIC b2IRectangleFromRectangle(const tools::Rectangle&); |
164 | | basegfx::B2IRectangle VCL_DLLPUBLIC b2IRectangleFromClosedRectangle(const tools::Rectangle&); |
165 | | |
166 | | } |
167 | | |
168 | | #endif // INCLUDED_VCL_CANVASTOOLS_HXX |
169 | | |
170 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |