Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / canvastools.hxx
blobe2abfb32bbe1780ac5ad842f42ea6c8bef6cdbfa
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 <com/sun/star/rendering/XColorSpace.hpp>
26 #include <basegfx/numeric/ftools.hxx>
27 #include <basegfx/range/b2irectangle.hxx>
29 #include <vcl/dllapi.h>
31 class Point;
32 class Size;
33 namespace tools { class Rectangle; }
34 namespace tools {
35 class Polygon;
36 class PolyPolygon;
38 class Bitmap;
39 class BitmapEx;
40 class Color;
42 namespace basegfx
44 class B2DVector;
45 class B2DPoint;
46 class B2DRange;
47 class B2IPoint;
48 class B2IRange;
51 namespace com { namespace sun { namespace star { namespace geometry
53 struct RealSize2D;
54 struct IntegerPoint2D;
55 struct IntegerSize2D;
56 struct IntegerRectangle2D;
57 } } } }
59 namespace com { namespace sun { namespace star { namespace rendering
61 class XGraphicDevice;
62 class XBitmap;
63 class XIntegerBitmap;
64 class XIntegerReadOnlyBitmap;
65 } } } }
67 namespace vcl
69 namespace unotools
71 // Bitmap conversions
74 /** Create an XBitmap from VCL BitmapEx
76 css::uno::Reference< css::rendering::XBitmap >
77 VCL_DLLPUBLIC xBitmapFromBitmapEx( const css::uno::Reference< css::rendering::XGraphicDevice >& xGraphicDevice,
78 const ::BitmapEx& inputBitmap );
80 /** Create a BitmapEx from an XBitmap
82 ::BitmapEx VCL_DLLPUBLIC bitmapExFromXBitmap( const css::uno::Reference< css::rendering::XIntegerReadOnlyBitmap >& xInputBitmap );
84 // Color conversions (vcl/tools Color <-> canvas standard color space)
87 /** Create a device-specific color sequence from VCL/Tools color
89 Note that this method assumes a color space equivalent to
90 the one returned from createStandardColorSpace()
92 css::uno::Sequence< double >
93 VCL_DLLPUBLIC colorToStdColorSpaceSequence( const Color& rColor );
95 /** Convert color to device color sequence
97 @param rColor
98 Color to convert
100 @param xColorSpace
101 Color space to convert into
103 css::uno::Sequence< double >
104 VCL_DLLPUBLIC colorToDoubleSequence( const Color& rColor,
105 const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace );
107 /** Convert from standard device color space to VCL/Tools color
109 Note that this method assumes a color space equivalent to
110 the one returned from createStandardColorSpace()
112 Color VCL_DLLPUBLIC stdColorSpaceSequenceToColor(
113 const css::uno::Sequence< double >& rColor );
115 /** Convert color to device color sequence
117 @param rColor
118 Color sequence to convert from
120 @param xColorSpace
121 Color space to convert from
123 Color VCL_DLLPUBLIC doubleSequenceToColor( const css::uno::Sequence< double >& rColor,
124 const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace );
126 /// Convert [0,1] double value to [0,255] int
127 inline sal_Int8 toByteColor( double val )
129 return sal::static_int_cast<sal_Int8>(
130 basegfx::fround(val*255.0));
133 /// Convert [0,255] int value to [0,1] double value
134 inline double toDoubleColor( sal_uInt8 val )
136 return val / 255.0;
139 /// Create a standard color space suitable for VCL RGB color
140 css::uno::Reference< css::rendering::XColorSpace> VCL_DLLPUBLIC createStandardColorSpace();
142 // Geometry conversions (vcl/tools <-> x)
145 // geometry::Real
146 css::geometry::RealSize2D VCL_DLLPUBLIC size2DFromSize( const Size& );
148 Size VCL_DLLPUBLIC sizeFromRealSize2D( const css::geometry::RealSize2D& );
150 // geometry::Integer
151 css::geometry::IntegerSize2D VCL_DLLPUBLIC integerSize2DFromSize( const Size& );
153 Size VCL_DLLPUBLIC sizeFromIntegerSize2D( const css::geometry::IntegerSize2D& );
154 Point VCL_DLLPUBLIC pointFromIntegerPoint2D( const css::geometry::IntegerPoint2D& );
155 tools::Rectangle VCL_DLLPUBLIC rectangleFromIntegerRectangle2D( const css::geometry::IntegerRectangle2D& );
157 // basegfx::B2D
158 Size VCL_DLLPUBLIC sizeFromB2DSize( const basegfx::B2DVector& );
159 Point VCL_DLLPUBLIC pointFromB2DPoint( const basegfx::B2DPoint& );
160 tools::Rectangle VCL_DLLPUBLIC rectangleFromB2DRectangle( const basegfx::B2DRange& );
162 basegfx::B2DVector VCL_DLLPUBLIC b2DSizeFromSize( const Size& );
163 basegfx::B2DPoint VCL_DLLPUBLIC b2DPointFromPoint( const Point& );
164 basegfx::B2DRange VCL_DLLPUBLIC b2DRectangleFromRectangle( const tools::Rectangle& );
166 // basegfx::B2I
167 Point VCL_DLLPUBLIC pointFromB2IPoint( const basegfx::B2IPoint& );
168 tools::Rectangle VCL_DLLPUBLIC rectangleFromB2IRectangle( const basegfx::B2IRange& );
169 basegfx::B2IPoint VCL_DLLPUBLIC b2IPointFromPoint(const Point&);
170 basegfx::B2IRectangle VCL_DLLPUBLIC b2IRectangleFromRectangle(const tools::Rectangle&);
174 #endif // INCLUDED_VCL_CANVASTOOLS_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */