Bump version to 21.06.18.1
[LibreOffice.git] / include / vcl / canvastools.hxx
blob5a46886e59b4b4c62d9c2a4c70220ccb076edad9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_CANVASTOOLS_HXX
21 #define INCLUDED_VCL_CANVASTOOLS_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <basegfx/numeric/ftools.hxx>
26 #include <basegfx/range/b2irectangle.hxx>
28 #include <vcl/dllapi.h>
30 class Point;
31 class Size;
32 namespace tools { class Rectangle; }
33 class BitmapEx;
34 class Color;
36 namespace basegfx
38 class B2DVector;
39 class B2DPoint;
40 class B2DRange;
41 class B2IPoint;
42 class B2IRange;
45 namespace com::sun::star::geometry
47 struct RealSize2D;
48 struct IntegerPoint2D;
49 struct IntegerSize2D;
50 struct IntegerRectangle2D;
53 namespace com::sun::star::rendering
55 class XBitmap;
56 class XIntegerReadOnlyBitmap;
59 namespace com::sun::star::rendering { class XColorSpace; }
61 namespace vcl::unotools
63 // Bitmap conversions
66 /** Create an XBitmap from VCL BitmapEx
68 css::uno::Reference< css::rendering::XBitmap >
69 VCL_DLLPUBLIC xBitmapFromBitmapEx( const ::BitmapEx& inputBitmap );
71 /** Create a BitmapEx from an XBitmap
73 ::BitmapEx VCL_DLLPUBLIC bitmapExFromXBitmap( const css::uno::Reference< css::rendering::XIntegerReadOnlyBitmap >& xInputBitmap );
75 // Color conversions (vcl/tools Color <-> canvas standard color space)
78 /** Create a device-specific color sequence from VCL/Tools color
80 Note that this method assumes a color space equivalent to
81 the one returned from createStandardColorSpace()
83 css::uno::Sequence< double >
84 VCL_DLLPUBLIC colorToStdColorSpaceSequence( const Color& rColor );
86 /** Convert color to device color sequence
88 @param rColor
89 Color to convert
91 @param xColorSpace
92 Color space to convert into
94 css::uno::Sequence< double >
95 VCL_DLLPUBLIC colorToDoubleSequence( const Color& rColor,
96 const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace );
98 /** Convert from standard device color space to VCL/Tools color
100 Note that this method assumes a color space equivalent to
101 the one returned from createStandardColorSpace()
103 Color VCL_DLLPUBLIC stdColorSpaceSequenceToColor(
104 const css::uno::Sequence< double >& rColor );
106 /** Convert color to device color sequence
108 @param rColor
109 Color sequence to convert from
111 @param xColorSpace
112 Color space to convert from
114 Color VCL_DLLPUBLIC doubleSequenceToColor( const css::uno::Sequence< double >& rColor,
115 const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace );
117 /// Convert [0,1] double value to [0,255] int
118 inline sal_Int8 toByteColor( double val )
120 return sal::static_int_cast<sal_Int8>(
121 basegfx::fround(val*255.0));
124 /// Convert [0,255] int value to [0,1] double value
125 inline double toDoubleColor( sal_uInt8 val )
127 return val / 255.0;
130 /// Create a standard color space suitable for VCL RGB color
131 css::uno::Reference< css::rendering::XColorSpace> VCL_DLLPUBLIC createStandardColorSpace();
133 // Geometry conversions (vcl/tools <-> x)
136 // geometry::Real
137 css::geometry::RealSize2D VCL_DLLPUBLIC size2DFromSize( const Size& );
139 Size VCL_DLLPUBLIC sizeFromRealSize2D( const css::geometry::RealSize2D& );
141 // geometry::Integer
142 css::geometry::IntegerSize2D VCL_DLLPUBLIC integerSize2DFromSize( const Size& );
144 Size VCL_DLLPUBLIC sizeFromIntegerSize2D( const css::geometry::IntegerSize2D& );
145 Point VCL_DLLPUBLIC pointFromIntegerPoint2D( const css::geometry::IntegerPoint2D& );
146 tools::Rectangle VCL_DLLPUBLIC rectangleFromIntegerRectangle2D( const css::geometry::IntegerRectangle2D& );
148 // basegfx::B2D
149 Size VCL_DLLPUBLIC sizeFromB2DSize( const basegfx::B2DVector& );
150 Point VCL_DLLPUBLIC pointFromB2DPoint( const basegfx::B2DPoint& );
151 tools::Rectangle VCL_DLLPUBLIC rectangleFromB2DRectangle( const basegfx::B2DRange& );
153 basegfx::B2DVector VCL_DLLPUBLIC b2DSizeFromSize( const Size& );
154 basegfx::B2DPoint VCL_DLLPUBLIC b2DPointFromPoint( const Point& );
155 basegfx::B2DRange VCL_DLLPUBLIC b2DRectangleFromRectangle( const tools::Rectangle& );
157 // basegfx::B2I
158 Point VCL_DLLPUBLIC pointFromB2IPoint( const basegfx::B2IPoint& );
159 tools::Rectangle VCL_DLLPUBLIC rectangleFromB2IRectangle( const basegfx::B2IRange& );
160 basegfx::B2IPoint VCL_DLLPUBLIC b2IPointFromPoint(const Point&);
161 basegfx::B2IRectangle VCL_DLLPUBLIC b2IRectangleFromRectangle(const tools::Rectangle&);
165 #endif // INCLUDED_VCL_CANVASTOOLS_HXX
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */