1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <basegfx/numeric/ftools.hxx>
24 #include <canvas/debug.hxx>
25 #include <canvas/verbosetrace.hxx>
26 #include <tools/diagnose_ex.h>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XUnoTunnel.hpp>
30 #include <com/sun/star/geometry/RealPoint2D.hpp>
31 #include <com/sun/star/geometry/IntegerRectangle2D.hpp>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
34 #include <basegfx/range/b2irectangle.hxx>
35 #include <basegfx/range/b2drectangle.hxx>
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 #include <basegfx/polygon/b2dpolypolygon.hxx>
38 #include <basegfx/tools/canvastools.hxx>
40 #include <canvas/canvastools.hxx>
41 #include <canvas/verifyinput.hxx>
43 #include "dx_impltools.hxx"
44 #include "dx_vcltools.hxx"
45 #include "dx_linepolypolygon.hxx"
46 #include "dx_canvasbitmap.hxx"
47 #include "dx_canvasfont.hxx"
48 #include "dx_canvas.hxx"
49 #include "dx_spritecanvas.hxx"
51 #include <boost/scoped_array.hpp>
57 using namespace ::com::sun::star
;
64 ::basegfx::B2DPolyPolygon
polyPolygonFromXPolyPolygon2D( const uno::Reference
< rendering::XPolyPolygon2D
>& xPoly
)
66 LinePolyPolygon
* pPolyImpl
= dynamic_cast< LinePolyPolygon
* >( xPoly
.get() );
70 return pPolyImpl
->getPolyPolygon();
74 const sal_Int32
nPolys( xPoly
->getNumberOfPolygons() );
76 // not a known implementation object - try data source
78 uno::Reference
< rendering::XBezierPolyPolygon2D
> xBezierPoly(
82 if( xBezierPoly
.is() )
84 return ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence(
85 xBezierPoly
->getBezierSegments( 0,
92 uno::Reference
< rendering::XLinePolyPolygon2D
> xLinePoly(
96 // no implementation class and no data provider
97 // found - contract violation.
98 ENSURE_ARG_OR_THROW( xLinePoly
.is(),
99 "VCLCanvas::polyPolygonFromXPolyPolygon2D(): Invalid input "
100 "poly-polygon, cannot retrieve vertex data" );
102 return ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence(
103 xLinePoly
->getPoints( 0,
111 void setupGraphics( Gdiplus::Graphics
& rGraphics
)
113 // setup graphics with (somewhat arbitrary) defaults
114 //rGraphics.SetCompositingQuality( Gdiplus::CompositingQualityHighQuality );
115 rGraphics
.SetCompositingQuality( Gdiplus::CompositingQualityHighSpeed
);
116 //rGraphics.SetInterpolationMode( Gdiplus::InterpolationModeHighQualityBilinear ); // with prefiltering for shrinks
117 rGraphics
.SetInterpolationMode( Gdiplus::InterpolationModeBilinear
);
119 // #122683# Switched precedence of pixel offset
120 // mode. Seemingly, polygon stroking needs
121 // PixelOffsetModeNone to achieve visually pleasing
122 // results, whereas all other operations (e.g. polygon
123 // fills, bitmaps) look better with PixelOffsetModeHalf.
124 rGraphics
.SetPixelOffsetMode( Gdiplus::PixelOffsetModeHalf
); // Pixel center at (0.5, 0.5) etc.
125 //rGraphics.SetPixelOffsetMode( Gdiplus::PixelOffsetModeNone );
127 //rGraphics.SetSmoothingMode( Gdiplus::SmoothingModeHighSpeed ); // no line/curve antialiasing
128 //rGraphics.SetSmoothingMode( Gdiplus::SmoothingModeHighQuality );
129 rGraphics
.SetSmoothingMode( Gdiplus::SmoothingModeAntiAlias
);
130 //rGraphics.SetTextRenderingHint( Gdiplus::TextRenderingHintAntiAlias );
131 rGraphics
.SetTextRenderingHint( Gdiplus::TextRenderingHintSystemDefault
);
132 rGraphics
.SetPageUnit(Gdiplus::UnitPixel
);
135 Gdiplus::Graphics
* createGraphicsFromHDC(HDC aHDC
)
137 Gdiplus::Graphics
* pRet
= new Gdiplus::Graphics(aHDC
);
138 setupGraphics( *pRet
);
142 Gdiplus::Graphics
* createGraphicsFromBitmap(const BitmapSharedPtr
& rBitmap
)
144 Gdiplus::Graphics
* pRet
= Gdiplus::Graphics::FromImage(rBitmap
.get());
146 setupGraphics( *pRet
);
150 void gdiPlusMatrixFromB2DHomMatrix( Gdiplus::Matrix
& rGdiplusMatrix
, const ::basegfx::B2DHomMatrix
& rMatrix
)
152 rGdiplusMatrix
.SetElements( static_cast<Gdiplus::REAL
>(rMatrix
.get(0,0)),
153 static_cast<Gdiplus::REAL
>(rMatrix
.get(1,0)),
154 static_cast<Gdiplus::REAL
>(rMatrix
.get(0,1)),
155 static_cast<Gdiplus::REAL
>(rMatrix
.get(1,1)),
156 static_cast<Gdiplus::REAL
>(rMatrix
.get(0,2)),
157 static_cast<Gdiplus::REAL
>(rMatrix
.get(1,2)) );
160 void gdiPlusMatrixFromAffineMatrix2D( Gdiplus::Matrix
& rGdiplusMatrix
,
161 const geometry::AffineMatrix2D
& rMatrix
)
163 rGdiplusMatrix
.SetElements( static_cast<Gdiplus::REAL
>(rMatrix
.m00
),
164 static_cast<Gdiplus::REAL
>(rMatrix
.m10
),
165 static_cast<Gdiplus::REAL
>(rMatrix
.m01
),
166 static_cast<Gdiplus::REAL
>(rMatrix
.m11
),
167 static_cast<Gdiplus::REAL
>(rMatrix
.m02
),
168 static_cast<Gdiplus::REAL
>(rMatrix
.m12
) );
173 // TODO(P2): Check whether this gets inlined. If not, make functor
175 inline Gdiplus::PointF
implGdiPlusPointFromRealPoint2D( const ::com::sun::star::geometry::RealPoint2D
& rPoint
)
177 return Gdiplus::PointF( static_cast<Gdiplus::REAL
>(rPoint
.X
),
178 static_cast<Gdiplus::REAL
>(rPoint
.Y
) );
181 void graphicsPathFromB2DPolygon( GraphicsPathSharedPtr
& rOutput
,
182 ::std::vector
< Gdiplus::PointF
>& rPoints
,
183 const ::basegfx::B2DPolygon
& rPoly
,
186 const sal_uInt32
nPoints( rPoly
.count() );
191 rOutput
->StartFigure();
193 const bool bClosedPolygon( rPoly
.isClosed() );
195 if( rPoly
.areControlPointsUsed() )
197 // control points used -> for now, add all
198 // segments as curves to GraphicsPath
200 // If the polygon is closed, we need to add the
201 // first point, thus, one more (can't simply
202 // GraphicsPath::CloseFigure() it, since the last
203 // point cannot have any control points for GDI+)
204 rPoints
.resize( 3*nPoints
+ bClosedPolygon
);
206 sal_uInt32 nCurrOutput
=0;
207 for( sal_uInt32 nCurrPoint
=0; nCurrPoint
<nPoints
; ++nCurrPoint
)
209 const ::basegfx::B2DPoint
& rPoint( rPoly
.getB2DPoint( nCurrPoint
) );
210 rPoints
[nCurrOutput
++] = Gdiplus::PointF( static_cast<Gdiplus::REAL
>(rPoint
.getX()),
211 static_cast<Gdiplus::REAL
>(rPoint
.getY()) );
213 const ::basegfx::B2DPoint
& rControlPointA( rPoly
.getNextControlPoint( nCurrPoint
) );
214 rPoints
[nCurrOutput
++] = Gdiplus::PointF( static_cast<Gdiplus::REAL
>(rControlPointA
.getX()),
215 static_cast<Gdiplus::REAL
>(rControlPointA
.getY()) );
217 const ::basegfx::B2DPoint
& rControlPointB( rPoly
.getPrevControlPoint( (nCurrPoint
+ 1) % nPoints
) );
218 rPoints
[nCurrOutput
++] = Gdiplus::PointF( static_cast<Gdiplus::REAL
>(rControlPointB
.getX()),
219 static_cast<Gdiplus::REAL
>(rControlPointB
.getY()) );
224 // add first point again (to be able to pass
225 // control points for the last point, see
227 const ::basegfx::B2DPoint
& rPoint( rPoly
.getB2DPoint(0) );
228 rPoints
[nCurrOutput
++] = Gdiplus::PointF( static_cast<Gdiplus::REAL
>(rPoint
.getX()),
229 static_cast<Gdiplus::REAL
>(rPoint
.getY()) );
231 if(bNoLineJoin
&& nCurrOutput
> 7)
233 for(sal_uInt32
a(3); a
< nCurrOutput
; a
+=3)
235 rOutput
->StartFigure();
236 rOutput
->AddBezier(rPoints
[a
- 3], rPoints
[a
- 2], rPoints
[a
- 1], rPoints
[a
]);
241 rOutput
->AddBeziers( &rPoints
[0], nCurrOutput
);
246 // GraphicsPath expects 3(n-1)+1 points (i.e. the
247 // last point must not have any trailing control
249 // Therefore, simply don't pass the last two
251 if( nCurrOutput
> 3 )
253 if(bNoLineJoin
&& nCurrOutput
> 7)
255 for(sal_uInt32
a(3); a
< nCurrOutput
; a
+=3)
257 rOutput
->StartFigure();
258 rOutput
->AddBezier(rPoints
[a
- 3], rPoints
[a
- 2], rPoints
[a
- 1], rPoints
[a
]);
263 rOutput
->AddBeziers( &rPoints
[0], nCurrOutput
-2 );
270 // no control points -> no curves, simply add
271 // straigt lines to GraphicsPath
272 rPoints
.resize( nPoints
);
274 for( sal_uInt32 nCurrPoint
=0; nCurrPoint
<nPoints
; ++nCurrPoint
)
276 const ::basegfx::B2DPoint
& rPoint( rPoly
.getB2DPoint( nCurrPoint
) );
277 rPoints
[nCurrPoint
] = Gdiplus::PointF( static_cast<Gdiplus::REAL
>(rPoint
.getX()),
278 static_cast<Gdiplus::REAL
>(rPoint
.getY()) );
281 if(bNoLineJoin
&& nPoints
> 2)
283 for(sal_uInt32
a(1); a
< nPoints
; a
++)
285 rOutput
->StartFigure();
286 rOutput
->AddLine(rPoints
[a
- 1], rPoints
[a
]);
291 rOutput
->StartFigure();
292 rOutput
->AddLine(rPoints
[nPoints
- 1], rPoints
[0]);
297 rOutput
->AddLines( &rPoints
[0], nPoints
);
301 if( bClosedPolygon
&& !bNoLineJoin
)
302 rOutput
->CloseFigure();
306 Gdiplus::PointF
gdiPlusPointFromRealPoint2D( const ::com::sun::star::geometry::RealPoint2D
& rPoint
)
308 return implGdiPlusPointFromRealPoint2D( rPoint
);
311 Gdiplus::Rect
gdiPlusRectFromIntegerRectangle2D( const geometry::IntegerRectangle2D
& rRect
)
313 return Gdiplus::Rect( rRect
.X1
,
316 rRect
.Y2
- rRect
.Y1
);
319 Gdiplus::RectF
gdiPlusRectFFromRectangle2D( const geometry::RealRectangle2D
& rRect
)
321 return Gdiplus::RectF( static_cast<Gdiplus::REAL
>(rRect
.X1
),
322 static_cast<Gdiplus::REAL
>(rRect
.Y1
),
323 static_cast<Gdiplus::REAL
>(rRect
.X2
- rRect
.X1
),
324 static_cast<Gdiplus::REAL
>(rRect
.Y2
- rRect
.Y1
) );
327 RECT
gdiRectFromB2IRect( const ::basegfx::B2IRange
& rRect
)
329 RECT aRect
= {rRect
.getMinX(),
337 geometry::RealPoint2D
realPoint2DFromGdiPlusPointF( const Gdiplus::PointF
& rPoint
)
339 return geometry::RealPoint2D( rPoint
.X
, rPoint
.Y
);
342 geometry::RealRectangle2D
realRectangle2DFromGdiPlusRectF( const Gdiplus::RectF
& rRect
)
344 return geometry::RealRectangle2D( rRect
.X
, rRect
.Y
,
345 rRect
.X
+ rRect
.Width
,
346 rRect
.Y
+ rRect
.Height
);
349 ::basegfx::B2DPoint
b2dPointFromGdiPlusPointF( const Gdiplus::PointF
& rPoint
)
351 return ::basegfx::B2DPoint( rPoint
.X
, rPoint
.Y
);
354 ::basegfx::B2DRange
b2dRangeFromGdiPlusRectF( const Gdiplus::RectF
& rRect
)
356 return ::basegfx::B2DRange( rRect
.X
, rRect
.Y
,
357 rRect
.X
+ rRect
.Width
,
358 rRect
.Y
+ rRect
.Height
);
361 uno::Sequence
< double > argbToDoubleSequence( const Gdiplus::ARGB
& rColor
)
363 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
364 uno::Sequence
< double > aRet(4);
366 aRet
[0] = ((rColor
>> 16) & 0xFF) / 255.0; // red
367 aRet
[1] = ((rColor
>> 8) & 0xFF) / 255.0; // green
368 aRet
[2] = (rColor
& 0xFF) / 255.0; // blue
369 aRet
[3] = ((rColor
>> 24) & 0xFF) / 255.0; // alpha
374 uno::Sequence
< sal_Int8
> argbToIntSequence( const Gdiplus::ARGB
& rColor
)
376 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
377 uno::Sequence
< sal_Int8
> aRet(4);
379 aRet
[0] = static_cast<sal_Int8
>((rColor
>> 16) & 0xFF); // red
380 aRet
[1] = static_cast<sal_Int8
>((rColor
>> 8) & 0xFF); // green
381 aRet
[2] = static_cast<sal_Int8
>(rColor
& 0xFF); // blue
382 aRet
[3] = static_cast<sal_Int8
>((rColor
>> 24) & 0xFF); // alpha
387 Gdiplus::ARGB
sequenceToArgb( const uno::Sequence
< sal_Int8
>& rColor
)
389 ENSURE_OR_THROW( rColor
.getLength() > 2,
390 "sequenceToArgb: need at least three channels" );
392 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
393 Gdiplus::ARGB aColor
;
395 aColor
= (static_cast<sal_uInt8
>(rColor
[0]) << 16) | (static_cast<sal_uInt8
>(rColor
[1]) << 8) | static_cast<sal_uInt8
>(rColor
[2]);
397 if( rColor
.getLength() > 3 )
398 aColor
|= static_cast<sal_uInt8
>(rColor
[3]) << 24;
403 Gdiplus::ARGB
sequenceToArgb( const uno::Sequence
< double >& rColor
)
405 ENSURE_OR_THROW( rColor
.getLength() > 2,
406 "sequenceToColor: need at least three channels" );
408 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
409 Gdiplus::ARGB aColor
;
411 ::canvas::tools::verifyRange(rColor
[0],0.0,1.0);
412 ::canvas::tools::verifyRange(rColor
[1],0.0,1.0);
413 ::canvas::tools::verifyRange(rColor
[2],0.0,1.0);
416 (static_cast<sal_uInt8
>( ::basegfx::fround( 255*rColor
[0] ) ) << 16) |
417 (static_cast<sal_uInt8
>( ::basegfx::fround( 255*rColor
[1] ) ) << 8) |
418 static_cast<sal_uInt8
>( ::basegfx::fround( 255*rColor
[2] ) );
420 if( rColor
.getLength() > 3 )
422 ::canvas::tools::verifyRange(rColor
[3],0.0,1.0);
423 aColor
|= static_cast<sal_uInt8
>( ::basegfx::fround( 255*rColor
[3] ) ) << 24;
429 GraphicsPathSharedPtr
graphicsPathFromRealPoint2DSequence( const uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> >& points
)
431 GraphicsPathSharedPtr
pRes( new Gdiplus::GraphicsPath() );
432 ::std::vector
< Gdiplus::PointF
> aPoints
;
435 for( nCurrPoly
=0; nCurrPoly
<points
.getLength(); ++nCurrPoly
)
437 const sal_Int32
nCurrSize( points
[nCurrPoly
].getLength() );
440 aPoints
.resize( nCurrSize
);
442 // TODO(F1): Closed/open polygons
444 // convert from RealPoint2D array to Gdiplus::PointF array
445 ::std::transform( points
[nCurrPoly
].getConstArray(),
446 points
[nCurrPoly
].getConstArray()+nCurrSize
,
448 implGdiPlusPointFromRealPoint2D
);
450 pRes
->AddLines( &aPoints
[0], nCurrSize
);
457 GraphicsPathSharedPtr
graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon
& rPoly
, bool bNoLineJoin
)
459 GraphicsPathSharedPtr
pRes( new Gdiplus::GraphicsPath() );
460 ::std::vector
< Gdiplus::PointF
> aPoints
;
462 graphicsPathFromB2DPolygon( pRes
, aPoints
, rPoly
, bNoLineJoin
);
467 GraphicsPathSharedPtr
graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon
& rPoly
, bool bNoLineJoin
)
469 GraphicsPathSharedPtr
pRes( new Gdiplus::GraphicsPath() );
470 ::std::vector
< Gdiplus::PointF
> aPoints
;
472 const sal_uInt32
nPolies( rPoly
.count() );
473 for( sal_uInt32 nCurrPoly
=0; nCurrPoly
<nPolies
; ++nCurrPoly
)
475 graphicsPathFromB2DPolygon( pRes
,
477 rPoly
.getB2DPolygon( nCurrPoly
),
484 GraphicsPathSharedPtr
graphicsPathFromXPolyPolygon2D( const uno::Reference
< rendering::XPolyPolygon2D
>& xPoly
, bool bNoLineJoin
)
486 LinePolyPolygon
* pPolyImpl
= dynamic_cast< LinePolyPolygon
* >( xPoly
.get() );
490 return pPolyImpl
->getGraphicsPath( bNoLineJoin
);
494 return tools::graphicsPathFromB2DPolyPolygon(
495 polyPolygonFromXPolyPolygon2D( xPoly
), bNoLineJoin
);
499 bool drawGdiPlusBitmap( const GraphicsSharedPtr
& rGraphics
,
500 const BitmapSharedPtr
& rBitmap
)
502 Gdiplus::PointF aPoint
;
503 return (Gdiplus::Ok
== rGraphics
->DrawImage( rBitmap
.get(),
507 bool drawDIBits( const GraphicsSharedPtr
& rGraphics
,
508 const BITMAPINFO
& rBI
,
511 BitmapSharedPtr
pBitmap(
512 Gdiplus::Bitmap::FromBITMAPINFO( &rBI
,
515 return drawGdiPlusBitmap( rGraphics
,
519 bool drawRGBABits( const GraphicsSharedPtr
& rGraphics
,
520 const RawRGBABitmap
& rRawRGBAData
)
522 BitmapSharedPtr
pBitmap( new Gdiplus::Bitmap( rRawRGBAData
.mnWidth
,
523 rRawRGBAData
.mnHeight
,
524 PixelFormat32bppARGB
) );
526 Gdiplus::BitmapData aBmpData
;
527 aBmpData
.Width
= rRawRGBAData
.mnWidth
;
528 aBmpData
.Height
= rRawRGBAData
.mnHeight
;
529 aBmpData
.Stride
= 4*aBmpData
.Width
; // bottom-up format
530 aBmpData
.PixelFormat
= PixelFormat32bppARGB
;
531 aBmpData
.Scan0
= rRawRGBAData
.mpBitmapData
.get();
533 const Gdiplus::Rect
aRect( 0,0,aBmpData
.Width
,aBmpData
.Height
);
534 if( Gdiplus::Ok
!= pBitmap
->LockBits( &aRect
,
535 Gdiplus::ImageLockModeWrite
| Gdiplus::ImageLockModeUserInputBuf
,
536 PixelFormat32bppARGB
,
542 // commit data to bitmap
543 pBitmap
->UnlockBits( &aBmpData
);
545 return drawGdiPlusBitmap( rGraphics
,
549 BitmapSharedPtr
bitmapFromXBitmap( const uno::Reference
< rendering::XBitmap
>& xBitmap
)
551 BitmapProvider
* pBitmapProvider
= dynamic_cast< BitmapProvider
* >(xBitmap
.get());
553 if( pBitmapProvider
)
555 IBitmapSharedPtr
pBitmap( pBitmapProvider
->getBitmap() );
556 return pBitmap
->getBitmap();
560 // not a native CanvasBitmap, extract VCL bitmap and
561 // render into GDI+ bitmap of similar size
562 // =================================================
564 const geometry::IntegerSize2D
aBmpSize( xBitmap
->getSize() );
565 BitmapSharedPtr pBitmap
;
567 if( xBitmap
->hasAlpha() )
569 // TODO(P2): At least for the alpha bitmap case, it
570 // would be possible to generate the corresponding
572 pBitmap
.reset( new Gdiplus::Bitmap( aBmpSize
.Width
,
574 PixelFormat32bppARGB
) );
578 // TODO(F2): Might be wise to create bitmap compatible
579 // to the VCL bitmap. Also, check whether the VCL
580 // bitmap's system handles can be used to create the
581 // GDI+ bitmap (currently, it does not seem so).
582 pBitmap
.reset( new Gdiplus::Bitmap( aBmpSize
.Width
,
584 PixelFormat24bppRGB
) );
587 GraphicsSharedPtr
pGraphics(createGraphicsFromBitmap(pBitmap
));
588 tools::setupGraphics(*pGraphics
);
589 if( !drawVCLBitmapFromXBitmap(
600 CanvasFont::ImplRef
canvasFontFromXFont( const uno::Reference
< rendering::XCanvasFont
>& xFont
)
602 CanvasFont
* pCanvasFont
= dynamic_cast< CanvasFont
* >(xFont
.get());
604 ENSURE_ARG_OR_THROW( pCanvasFont
,
605 "canvasFontFromXFont(): Invalid XFont (or incompatible font for this XCanvas)" );
607 return CanvasFont::ImplRef( pCanvasFont
);
610 void setModulateImageAttributes( Gdiplus::ImageAttributes
& o_rAttr
,
611 double nRedModulation
,
612 double nGreenModulation
,
613 double nBlueModulation
,
614 double nAlphaModulation
)
616 // This gets rather verbose, but we have to setup a color
617 // transformation matrix, in order to incorporate the global
618 // alpha value mfAlpha into the bitmap rendering.
619 Gdiplus::ColorMatrix aColorMatrix
;
621 aColorMatrix
.m
[0][0] = static_cast<Gdiplus::REAL
>(nRedModulation
);
622 aColorMatrix
.m
[0][1] = 0.0;
623 aColorMatrix
.m
[0][2] = 0.0;
624 aColorMatrix
.m
[0][3] = 0.0;
625 aColorMatrix
.m
[0][4] = 0.0;
627 aColorMatrix
.m
[1][0] = 0.0;
628 aColorMatrix
.m
[1][1] = static_cast<Gdiplus::REAL
>(nGreenModulation
);
629 aColorMatrix
.m
[1][2] = 0.0;
630 aColorMatrix
.m
[1][3] = 0.0;
631 aColorMatrix
.m
[1][4] = 0.0;
633 aColorMatrix
.m
[2][0] = 0.0;
634 aColorMatrix
.m
[2][1] = 0.0;
635 aColorMatrix
.m
[2][2] = static_cast<Gdiplus::REAL
>(nBlueModulation
);
636 aColorMatrix
.m
[2][3] = 0.0;
637 aColorMatrix
.m
[2][4] = 0.0;
639 aColorMatrix
.m
[3][0] = 0.0;
640 aColorMatrix
.m
[3][1] = 0.0;
641 aColorMatrix
.m
[3][2] = 0.0;
642 aColorMatrix
.m
[3][3] = static_cast<Gdiplus::REAL
>(nAlphaModulation
);
643 aColorMatrix
.m
[3][4] = 0.0;
645 aColorMatrix
.m
[4][0] = 0.0;
646 aColorMatrix
.m
[4][1] = 0.0;
647 aColorMatrix
.m
[4][2] = 0.0;
648 aColorMatrix
.m
[4][3] = 0.0;
649 aColorMatrix
.m
[4][4] = 1.0;
651 o_rAttr
.SetColorMatrix( &aColorMatrix
,
652 Gdiplus::ColorMatrixFlagsDefault
,
653 Gdiplus::ColorAdjustTypeDefault
);
657 } // namespace dxcanvas
659 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */