Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _VCL_CANVASTOOLS_HXX
30 : : #define _VCL_CANVASTOOLS_HXX
31 : :
32 : : #include <com/sun/star/uno/Reference.hxx>
33 : : #include <com/sun/star/uno/Sequence.hxx>
34 : : #include <com/sun/star/rendering/XColorSpace.hpp>
35 : : #include <basegfx/numeric/ftools.hxx>
36 : :
37 : : #include <vcl/dllapi.h>
38 : :
39 : : class Point;
40 : : class Size;
41 : : class Rectangle;
42 : : class Polygon;
43 : : class PolyPolygon;
44 : : class Bitmap;
45 : : class BitmapEx;
46 : : class Color;
47 : :
48 : : namespace basegfx
49 : : {
50 : : class B2DVector;
51 : : class B2DPoint;
52 : : class B2DRange;
53 : : class B2IVector;
54 : : class B2IPoint;
55 : : class B2IRange;
56 : : class B2DPolygon;
57 : : class B2DPolyPolygon;
58 : : }
59 : :
60 : : namespace com { namespace sun { namespace star { namespace geometry
61 : : {
62 : : struct RealPoint2D;
63 : : struct RealSize2D;
64 : : struct RealRectangle2D;
65 : : struct IntegerPoint2D;
66 : : struct IntegerSize2D;
67 : : struct IntegerRectangle2D;
68 : : struct RealBezierSegment2D;
69 : : } } } }
70 : :
71 : : namespace com { namespace sun { namespace star { namespace rendering
72 : : {
73 : : class XGraphicDevice;
74 : : class XBitmap;
75 : : class XIntegerBitmap;
76 : : class XIntegerReadOnlyBitmap;
77 : : class XPolyPolygon2D;
78 : : } } } }
79 : :
80 : : namespace vcl
81 : : {
82 : : namespace unotools
83 : : {
84 : : // Bitmap conversions
85 : : // ===================================================================
86 : :
87 : : /** Create an XBitmap from VCL BitmapEx
88 : : */
89 : : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
90 : : VCL_DLLPUBLIC xBitmapFromBitmapEx( const ::com::sun::star::uno::Reference<
91 : : ::com::sun::star::rendering::XGraphicDevice >& xGraphicDevice,
92 : : const ::BitmapEx& inputBitmap );
93 : :
94 : : /** Create a BitmapEx from an XBitmap
95 : : */
96 : : ::BitmapEx VCL_DLLPUBLIC bitmapExFromXBitmap( const ::com::sun::star::uno::Reference<
97 : : ::com::sun::star::rendering::XIntegerReadOnlyBitmap >& xInputBitmap );
98 : :
99 : : // Color conversions (vcl/tools Color <-> canvas standard color space)
100 : : // ===================================================================
101 : :
102 : : /** Convert color to device color sequence
103 : :
104 : : @param rColor
105 : : Color to convert
106 : :
107 : : @param xColorSpace
108 : : Color space to convert into
109 : : */
110 : : ::com::sun::star::uno::Sequence< double >
111 : : VCL_DLLPUBLIC colorToDoubleSequence( const Color& rColor,
112 : : const ::com::sun::star::uno::Reference<
113 : : ::com::sun::star::rendering::XColorSpace >& xColorSpace );
114 : :
115 : : /** Convert from standard device color space to VCL/Tools color
116 : :
117 : : Note that this method assumes a color space equivalent to
118 : : the one returned from createStandardColorSpace()
119 : : */
120 : : Color VCL_DLLPUBLIC stdColorSpaceSequenceToColor(
121 : : const ::com::sun::star::uno::Sequence< double >& rColor );
122 : :
123 : : /** Convert color to device color sequence
124 : :
125 : : @param rColor
126 : : Color sequence to convert from
127 : :
128 : : @param xColorSpace
129 : : Color space to convert from
130 : : */
131 : : Color VCL_DLLPUBLIC doubleSequenceToColor( const ::com::sun::star::uno::Sequence< double > rColor,
132 : : const ::com::sun::star::uno::Reference<
133 : : ::com::sun::star::rendering::XColorSpace >& xColorSpace );
134 : :
135 : : /// Convert [0,1] double value to [0,255] int
136 : 0 : inline sal_Int8 toByteColor( double val )
137 : : {
138 : : return sal::static_int_cast<sal_Int8>(
139 : 0 : basegfx::fround(val*255.0));
140 : : }
141 : :
142 : : /// Convert [0,255] int value to [0,1] double value
143 : 0 : inline double toDoubleColor( sal_uInt8 val )
144 : : {
145 : 0 : return val / 255.0;
146 : : }
147 : :
148 : : /// Create a standard color space suitable for VCL RGB color
149 : : ::com::sun::star::uno::Reference<
150 : : ::com::sun::star::rendering::XColorSpace> VCL_DLLPUBLIC createStandardColorSpace();
151 : :
152 : : // Geometry conversions (vcl/tools <-> x)
153 : : // ===================================================================
154 : :
155 : : // geometry::Real
156 : : ::com::sun::star::geometry::RealSize2D VCL_DLLPUBLIC size2DFromSize( const Size& );
157 : :
158 : : Size VCL_DLLPUBLIC sizeFromRealSize2D( const ::com::sun::star::geometry::RealSize2D& );
159 : :
160 : : // geometry::Integer
161 : : ::com::sun::star::geometry::IntegerSize2D VCL_DLLPUBLIC integerSize2DFromSize( const Size& );
162 : :
163 : : Size VCL_DLLPUBLIC sizeFromIntegerSize2D( const ::com::sun::star::geometry::IntegerSize2D& );
164 : : Point VCL_DLLPUBLIC pointFromIntegerPoint2D( const ::com::sun::star::geometry::IntegerPoint2D& );
165 : : Rectangle VCL_DLLPUBLIC rectangleFromIntegerRectangle2D( const ::com::sun::star::geometry::IntegerRectangle2D& );
166 : :
167 : : // basegfx::B2D
168 : : Size VCL_DLLPUBLIC sizeFromB2DSize( const ::basegfx::B2DVector& );
169 : : Point VCL_DLLPUBLIC pointFromB2DPoint( const ::basegfx::B2DPoint& );
170 : : Rectangle VCL_DLLPUBLIC rectangleFromB2DRectangle( const ::basegfx::B2DRange& );
171 : :
172 : : basegfx::B2DVector VCL_DLLPUBLIC b2DSizeFromSize( const Size& );
173 : : basegfx::B2DPoint VCL_DLLPUBLIC b2DPointFromPoint( const Point& );
174 : : basegfx::B2DRange VCL_DLLPUBLIC b2DRectangleFromRectangle( const Rectangle& );
175 : :
176 : : // basegfx::B2I
177 : : Point VCL_DLLPUBLIC pointFromB2IPoint( const ::basegfx::B2IPoint& );
178 : : Rectangle VCL_DLLPUBLIC rectangleFromB2IRectangle( const ::basegfx::B2IRange& );
179 : : }
180 : : }
181 : :
182 : : #endif /* _VCL_CANVASTOOLS_HXX */
183 : :
184 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|