xref: /trunk/main/cppcanvas/source/tools/tools.cxx (revision 25b11142)
1*25b11142SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*25b11142SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*25b11142SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*25b11142SAndrew Rist  * distributed with this work for additional information
6*25b11142SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*25b11142SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*25b11142SAndrew Rist  * "License"); you may not use this file except in compliance
9*25b11142SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*25b11142SAndrew Rist  *
11*25b11142SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*25b11142SAndrew Rist  *
13*25b11142SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*25b11142SAndrew Rist  * software distributed under the License is distributed on an
15*25b11142SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*25b11142SAndrew Rist  * KIND, either express or implied.  See the License for the
17*25b11142SAndrew Rist  * specific language governing permissions and limitations
18*25b11142SAndrew Rist  * under the License.
19*25b11142SAndrew Rist  *
20*25b11142SAndrew Rist  *************************************************************/
21*25b11142SAndrew Rist 
22*25b11142SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cppcanvas.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir using namespace ::com::sun::star;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace cppcanvas
33cdf0e10cSrcweir {
34cdf0e10cSrcweir     namespace tools
35cdf0e10cSrcweir     {
intSRGBAToDoubleSequence(const uno::Reference<rendering::XGraphicDevice> &,Color::IntSRGBA aColor)36cdf0e10cSrcweir         uno::Sequence< double > intSRGBAToDoubleSequence( const uno::Reference< rendering::XGraphicDevice >&,
37cdf0e10cSrcweir                                                           Color::IntSRGBA 									aColor 	)
38cdf0e10cSrcweir         {
39cdf0e10cSrcweir             uno::Sequence< double > aRes( 4 );
40cdf0e10cSrcweir 
41cdf0e10cSrcweir             aRes[0] = getRed(aColor) / 255.0;
42cdf0e10cSrcweir             aRes[1] = getGreen(aColor) / 255.0;
43cdf0e10cSrcweir             aRes[2] = getBlue(aColor) / 255.0;
44cdf0e10cSrcweir             aRes[3] = getAlpha(aColor) / 255.0;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir             return aRes;
47cdf0e10cSrcweir         }
48cdf0e10cSrcweir 
doubleSequenceToIntSRGBA(const uno::Reference<rendering::XGraphicDevice> &,const uno::Sequence<double> & rColor)49cdf0e10cSrcweir         Color::IntSRGBA doubleSequenceToIntSRGBA( const uno::Reference< rendering::XGraphicDevice >&,
50cdf0e10cSrcweir                                                   const uno::Sequence< double >&					rColor 	)
51cdf0e10cSrcweir         {
52cdf0e10cSrcweir             return makeColor( static_cast<sal_uInt8>( 255*rColor[0] + .5 ),
53cdf0e10cSrcweir                               static_cast<sal_uInt8>( 255*rColor[1] + .5 ),
54cdf0e10cSrcweir                               static_cast<sal_uInt8>( 255*rColor[2] + .5 ),
55cdf0e10cSrcweir                               static_cast<sal_uInt8>( 255*rColor[3] + .5 ) );
56cdf0e10cSrcweir         }
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir }
59