update dev300-m58
[ooovba.git] / canvas / source / directx / dx_impltools.cxx
blob272fafb8c8786a36b633aa118879c6a420bd697d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dx_impltools.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_canvas.hxx"
34 #include <ctype.h> // don't ask. msdev breaks otherwise...
35 #include <basegfx/numeric/ftools.hxx>
37 #include <canvas/debug.hxx>
38 #include <canvas/verbosetrace.hxx>
39 #include <tools/diagnose_ex.h>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/lang/XUnoTunnel.hpp>
43 #include <com/sun/star/geometry/RealPoint2D.hpp>
44 #include <com/sun/star/geometry/IntegerRectangle2D.hpp>
46 #include <basegfx/matrix/b2dhommatrix.hxx>
47 #include <basegfx/range/b2irectangle.hxx>
48 #include <basegfx/range/b2drectangle.hxx>
49 #include <basegfx/polygon/b2dpolygon.hxx>
50 #include <basegfx/polygon/b2dpolypolygon.hxx>
51 #include <basegfx/tools/canvastools.hxx>
53 #include <canvas/canvastools.hxx>
54 #include <canvas/verifyinput.hxx>
56 #include "dx_impltools.hxx"
57 #include "dx_vcltools.hxx"
58 #include "dx_linepolypolygon.hxx"
59 #include "dx_canvasbitmap.hxx"
60 #include "dx_canvasfont.hxx"
61 #include "dx_canvas.hxx"
62 #include "dx_spritecanvas.hxx"
64 #include <boost/scoped_array.hpp>
66 #include <vector>
67 #include <algorithm>
70 using namespace ::com::sun::star;
73 namespace dxcanvas
75 namespace tools
77 ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly )
79 LinePolyPolygon* pPolyImpl = dynamic_cast< LinePolyPolygon* >( xPoly.get() );
81 if( pPolyImpl )
83 return pPolyImpl->getPolyPolygon();
85 else
87 const sal_Int32 nPolys( xPoly->getNumberOfPolygons() );
89 // not a known implementation object - try data source
90 // interfaces
91 uno::Reference< rendering::XBezierPolyPolygon2D > xBezierPoly(
92 xPoly,
93 uno::UNO_QUERY );
95 if( xBezierPoly.is() )
97 return ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence(
98 xBezierPoly->getBezierSegments( 0,
99 nPolys,
101 -1 ) );
103 else
105 uno::Reference< rendering::XLinePolyPolygon2D > xLinePoly(
106 xPoly,
107 uno::UNO_QUERY );
109 // no implementation class and no data provider
110 // found - contract violation.
111 ENSURE_ARG_OR_THROW( xLinePoly.is(),
112 "VCLCanvas::polyPolygonFromXPolyPolygon2D(): Invalid input "
113 "poly-polygon, cannot retrieve vertex data" );
115 return ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence(
116 xLinePoly->getPoints( 0,
117 nPolys,
119 -1 ) );
124 void setupGraphics( Gdiplus::Graphics& rGraphics )
126 // setup graphics with (somewhat arbitrary) defaults
127 //rGraphics.SetCompositingQuality( Gdiplus::CompositingQualityHighQuality );
128 rGraphics.SetCompositingQuality( Gdiplus::CompositingQualityHighSpeed );
129 //rGraphics.SetInterpolationMode( Gdiplus::InterpolationModeHighQualityBilinear ); // with prefiltering for shrinks
130 rGraphics.SetInterpolationMode( Gdiplus::InterpolationModeBilinear );
132 // #122683# Switched precedence of pixel offset
133 // mode. Seemingly, polygon stroking needs
134 // PixelOffsetModeNone to achieve visually pleasing
135 // results, whereas all other operations (e.g. polygon
136 // fills, bitmaps) look better with PixelOffsetModeHalf.
137 rGraphics.SetPixelOffsetMode( Gdiplus::PixelOffsetModeHalf ); // Pixel center at (0.5, 0.5) etc.
138 //rGraphics.SetPixelOffsetMode( Gdiplus::PixelOffsetModeNone );
140 //rGraphics.SetSmoothingMode( Gdiplus::SmoothingModeHighSpeed ); // no line/curve antialiasing
141 //rGraphics.SetSmoothingMode( Gdiplus::SmoothingModeHighQuality );
142 rGraphics.SetSmoothingMode( Gdiplus::SmoothingModeAntiAlias );
143 //rGraphics.SetTextRenderingHint( Gdiplus::TextRenderingHintAntiAlias );
144 rGraphics.SetTextRenderingHint( Gdiplus::TextRenderingHintSystemDefault );
145 rGraphics.SetPageUnit(Gdiplus::UnitPixel);
148 Gdiplus::Graphics* createGraphicsFromHDC(HDC aHDC)
150 Gdiplus::Graphics* pRet = new Gdiplus::Graphics(aHDC);
151 if( pRet )
152 setupGraphics( *pRet );
153 return pRet;
156 Gdiplus::Graphics* createGraphicsFromBitmap(const BitmapSharedPtr& rBitmap)
158 Gdiplus::Graphics* pRet = Gdiplus::Graphics::FromImage(rBitmap.get());
159 if( pRet )
160 setupGraphics( *pRet );
161 return pRet;
164 void gdiPlusMatrixFromB2DHomMatrix( Gdiplus::Matrix& rGdiplusMatrix, const ::basegfx::B2DHomMatrix& rMatrix )
166 rGdiplusMatrix.SetElements( static_cast<Gdiplus::REAL>(rMatrix.get(0,0)),
167 static_cast<Gdiplus::REAL>(rMatrix.get(1,0)),
168 static_cast<Gdiplus::REAL>(rMatrix.get(0,1)),
169 static_cast<Gdiplus::REAL>(rMatrix.get(1,1)),
170 static_cast<Gdiplus::REAL>(rMatrix.get(0,2)),
171 static_cast<Gdiplus::REAL>(rMatrix.get(1,2)) );
174 void gdiPlusMatrixFromAffineMatrix2D( Gdiplus::Matrix& rGdiplusMatrix,
175 const geometry::AffineMatrix2D& rMatrix )
177 rGdiplusMatrix.SetElements( static_cast<Gdiplus::REAL>(rMatrix.m00),
178 static_cast<Gdiplus::REAL>(rMatrix.m10),
179 static_cast<Gdiplus::REAL>(rMatrix.m01),
180 static_cast<Gdiplus::REAL>(rMatrix.m11),
181 static_cast<Gdiplus::REAL>(rMatrix.m02),
182 static_cast<Gdiplus::REAL>(rMatrix.m12) );
185 namespace
187 // TODO(P2): Check whether this gets inlined. If not, make functor
188 // out of it
189 inline Gdiplus::PointF implGdiPlusPointFromRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& rPoint )
191 return Gdiplus::PointF( static_cast<Gdiplus::REAL>(rPoint.X),
192 static_cast<Gdiplus::REAL>(rPoint.Y) );
195 void graphicsPathFromB2DPolygon( GraphicsPathSharedPtr& rOutput,
196 ::std::vector< Gdiplus::PointF >& rPoints,
197 const ::basegfx::B2DPolygon& rPoly )
199 const sal_uInt32 nPoints( rPoly.count() );
201 if( !nPoints )
202 return;
204 rOutput->StartFigure();
206 const bool bClosedPolygon( rPoly.isClosed() );
208 if( rPoly.areControlPointsUsed() )
210 // control points used -> for now, add all
211 // segments as curves to GraphicsPath
213 // If the polygon is closed, we need to add the
214 // first point, thus, one more (can't simply
215 // GraphicsPath::CloseFigure() it, since the last
216 // point cannot have any control points for GDI+)
217 rPoints.resize( 3*nPoints + bClosedPolygon );
219 sal_uInt32 nCurrOutput=0;
220 for( sal_uInt32 nCurrPoint=0; nCurrPoint<nPoints; ++nCurrPoint )
222 const ::basegfx::B2DPoint& rPoint( rPoly.getB2DPoint( nCurrPoint ) );
223 rPoints[nCurrOutput++] = Gdiplus::PointF( static_cast<Gdiplus::REAL>(rPoint.getX()),
224 static_cast<Gdiplus::REAL>(rPoint.getY()) );
226 const ::basegfx::B2DPoint& rControlPointA( rPoly.getNextControlPoint( nCurrPoint ) );
227 rPoints[nCurrOutput++] = Gdiplus::PointF( static_cast<Gdiplus::REAL>(rControlPointA.getX()),
228 static_cast<Gdiplus::REAL>(rControlPointA.getY()) );
230 const ::basegfx::B2DPoint& rControlPointB( rPoly.getPrevControlPoint( (nCurrPoint + 1) % nPoints) );
231 rPoints[nCurrOutput++] = Gdiplus::PointF( static_cast<Gdiplus::REAL>(rControlPointB.getX()),
232 static_cast<Gdiplus::REAL>(rControlPointB.getY()) );
235 if( bClosedPolygon )
237 // add first point again (to be able to pass
238 // control points for the last point, see
239 // above)
240 const ::basegfx::B2DPoint& rPoint( rPoly.getB2DPoint(0) );
241 rPoints[nCurrOutput++] = Gdiplus::PointF( static_cast<Gdiplus::REAL>(rPoint.getX()),
242 static_cast<Gdiplus::REAL>(rPoint.getY()) );
244 rOutput->AddBeziers( &rPoints[0], nCurrOutput );
246 else
248 // GraphicsPath expects 3(n-1)+1 points (i.e. the
249 // last point must not have any trailing control
250 // points after it).
251 // Therefore, simply don't pass the last two
252 // points here.
253 if( nCurrOutput > 3 )
254 rOutput->AddBeziers( &rPoints[0], nCurrOutput-2 );
257 else
259 // no control points -> no curves, simply add
260 // straigt lines to GraphicsPath
261 rPoints.resize( nPoints );
263 for( sal_uInt32 nCurrPoint=0; nCurrPoint<nPoints; ++nCurrPoint )
265 const ::basegfx::B2DPoint& rPoint( rPoly.getB2DPoint( nCurrPoint ) );
266 rPoints[nCurrPoint] = Gdiplus::PointF( static_cast<Gdiplus::REAL>(rPoint.getX()),
267 static_cast<Gdiplus::REAL>(rPoint.getY()) );
270 rOutput->AddLines( &rPoints[0], nPoints );
273 if( bClosedPolygon )
274 rOutput->CloseFigure();
278 Gdiplus::PointF gdiPlusPointFromRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& rPoint )
280 return implGdiPlusPointFromRealPoint2D( rPoint );
283 Gdiplus::Rect gdiPlusRectFromIntegerRectangle2D( const geometry::IntegerRectangle2D& rRect )
285 return Gdiplus::Rect( rRect.X1,
286 rRect.Y1,
287 rRect.X2 - rRect.X1,
288 rRect.Y2 - rRect.Y1 );
291 Gdiplus::RectF gdiPlusRectFFromRectangle2D( const geometry::RealRectangle2D& rRect )
293 return Gdiplus::RectF( static_cast<Gdiplus::REAL>(rRect.X1),
294 static_cast<Gdiplus::REAL>(rRect.Y1),
295 static_cast<Gdiplus::REAL>(rRect.X2 - rRect.X1),
296 static_cast<Gdiplus::REAL>(rRect.Y2 - rRect.Y1) );
299 RECT gdiRectFromB2IRect( const ::basegfx::B2IRange& rRect )
301 RECT aRect = {rRect.getMinX(),
302 rRect.getMinY(),
303 rRect.getMaxX(),
304 rRect.getMaxY()};
306 return aRect;
309 geometry::RealPoint2D realPoint2DFromGdiPlusPointF( const Gdiplus::PointF& rPoint )
311 return geometry::RealPoint2D( rPoint.X, rPoint.Y );
314 geometry::RealRectangle2D realRectangle2DFromGdiPlusRectF( const Gdiplus::RectF& rRect )
316 return geometry::RealRectangle2D( rRect.X, rRect.Y,
317 rRect.X + rRect.Width,
318 rRect.Y + rRect.Height );
321 ::basegfx::B2DPoint b2dPointFromGdiPlusPointF( const Gdiplus::PointF& rPoint )
323 return ::basegfx::B2DPoint( rPoint.X, rPoint.Y );
326 ::basegfx::B2DRange b2dRangeFromGdiPlusRectF( const Gdiplus::RectF& rRect )
328 return ::basegfx::B2DRange( rRect.X, rRect.Y,
329 rRect.X + rRect.Width,
330 rRect.Y + rRect.Height );
333 uno::Sequence< double > argbToDoubleSequence( const Gdiplus::ARGB& rColor )
335 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
336 uno::Sequence< double > aRet(4);
338 aRet[0] = ((rColor >> 16) & 0xFF) / 255.0; // red
339 aRet[1] = ((rColor >> 8) & 0xFF) / 255.0; // green
340 aRet[2] = (rColor & 0xFF) / 255.0; // blue
341 aRet[3] = ((rColor >> 24) & 0xFF) / 255.0; // alpha
343 return aRet;
346 uno::Sequence< sal_Int8 > argbToIntSequence( const Gdiplus::ARGB& rColor )
348 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
349 uno::Sequence< sal_Int8 > aRet(4);
351 aRet[0] = static_cast<sal_Int8>((rColor >> 16) & 0xFF); // red
352 aRet[1] = static_cast<sal_Int8>((rColor >> 8) & 0xFF); // green
353 aRet[2] = static_cast<sal_Int8>(rColor & 0xFF); // blue
354 aRet[3] = static_cast<sal_Int8>((rColor >> 24) & 0xFF); // alpha
356 return aRet;
359 Gdiplus::ARGB sequenceToArgb( const uno::Sequence< sal_Int8 >& rColor )
361 ENSURE_OR_THROW( rColor.getLength() > 2,
362 "sequenceToArgb: need at least three channels" );
364 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
365 Gdiplus::ARGB aColor;
367 aColor = (static_cast<sal_uInt8>(rColor[0]) << 16) | (static_cast<sal_uInt8>(rColor[1]) << 8) | static_cast<sal_uInt8>(rColor[2]);
369 if( rColor.getLength() > 3 )
370 aColor |= static_cast<sal_uInt8>(rColor[3]) << 24;
372 return aColor;
375 Gdiplus::ARGB sequenceToArgb( const uno::Sequence< double >& rColor )
377 ENSURE_OR_THROW( rColor.getLength() > 2,
378 "sequenceToColor: need at least three channels" );
380 // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
381 Gdiplus::ARGB aColor;
383 ::canvas::tools::verifyRange(rColor[0],0.0,1.0);
384 ::canvas::tools::verifyRange(rColor[1],0.0,1.0);
385 ::canvas::tools::verifyRange(rColor[2],0.0,1.0);
387 aColor =
388 (static_cast<sal_uInt8>( ::basegfx::fround( 255*rColor[0] ) ) << 16) |
389 (static_cast<sal_uInt8>( ::basegfx::fround( 255*rColor[1] ) ) << 8) |
390 static_cast<sal_uInt8>( ::basegfx::fround( 255*rColor[2] ) );
392 if( rColor.getLength() > 3 )
394 ::canvas::tools::verifyRange(rColor[3],0.0,1.0);
395 aColor |= static_cast<sal_uInt8>( ::basegfx::fround( 255*rColor[3] ) ) << 24;
398 return aColor;
401 GraphicsPathSharedPtr graphicsPathFromRealPoint2DSequence( const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points )
403 GraphicsPathSharedPtr pRes( new Gdiplus::GraphicsPath() );
404 ::std::vector< Gdiplus::PointF > aPoints;
406 sal_Int32 nCurrPoly;
407 for( nCurrPoly=0; nCurrPoly<points.getLength(); ++nCurrPoly )
409 const sal_Int32 nCurrSize( points[nCurrPoly].getLength() );
410 if( nCurrSize )
412 aPoints.resize( nCurrSize );
414 // TODO(F1): Closed/open polygons
416 // convert from RealPoint2D array to Gdiplus::PointF array
417 ::std::transform( const_cast< uno::Sequence< geometry::RealPoint2D >& >(points[nCurrPoly]).getArray(),
418 const_cast< uno::Sequence< geometry::RealPoint2D >& >(points[nCurrPoly]).getArray()+nCurrSize,
419 aPoints.begin(),
420 implGdiPlusPointFromRealPoint2D );
422 pRes->AddLines( &aPoints[0], nCurrSize );
426 return pRes;
429 GraphicsPathSharedPtr graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly )
431 GraphicsPathSharedPtr pRes( new Gdiplus::GraphicsPath() );
432 ::std::vector< Gdiplus::PointF > aPoints;
434 graphicsPathFromB2DPolygon( pRes, aPoints, rPoly );
436 return pRes;
439 GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly )
441 GraphicsPathSharedPtr pRes( new Gdiplus::GraphicsPath() );
442 ::std::vector< Gdiplus::PointF > aPoints;
444 const sal_uInt32 nPolies( rPoly.count() );
445 for( sal_uInt32 nCurrPoly=0; nCurrPoly<nPolies; ++nCurrPoly )
447 graphicsPathFromB2DPolygon( pRes,
448 aPoints,
449 rPoly.getB2DPolygon( nCurrPoly ) );
452 return pRes;
455 GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly )
457 LinePolyPolygon* pPolyImpl = dynamic_cast< LinePolyPolygon* >( xPoly.get() );
459 if( pPolyImpl )
461 return pPolyImpl->getGraphicsPath();
463 else
465 return tools::graphicsPathFromB2DPolyPolygon(
466 polyPolygonFromXPolyPolygon2D( xPoly ) );
470 bool drawGdiPlusBitmap( const GraphicsSharedPtr& rGraphics,
471 const BitmapSharedPtr& rBitmap )
473 Gdiplus::PointF aPoint;
474 return (Gdiplus::Ok == rGraphics->DrawImage( rBitmap.get(),
475 aPoint ) );
478 bool drawDIBits( const GraphicsSharedPtr& rGraphics,
479 const BITMAPINFO& rBI,
480 const void* pBits )
482 BitmapSharedPtr pBitmap(
483 Gdiplus::Bitmap::FromBITMAPINFO( &rBI,
484 (void*)pBits ) );
486 return drawGdiPlusBitmap( rGraphics,
487 pBitmap );
490 bool drawRGBABits( const GraphicsSharedPtr& rGraphics,
491 const RawRGBABitmap& rRawRGBAData )
493 BitmapSharedPtr pBitmap( new Gdiplus::Bitmap( rRawRGBAData.mnWidth,
494 rRawRGBAData.mnHeight,
495 PixelFormat32bppARGB ) );
497 Gdiplus::BitmapData aBmpData;
498 aBmpData.Width = rRawRGBAData.mnWidth;
499 aBmpData.Height = rRawRGBAData.mnHeight;
500 aBmpData.Stride = 4*aBmpData.Width; // bottom-up format
501 aBmpData.PixelFormat = PixelFormat32bppARGB;
502 aBmpData.Scan0 = rRawRGBAData.mpBitmapData.get();
504 const Gdiplus::Rect aRect( 0,0,aBmpData.Width,aBmpData.Height );
505 if( Gdiplus::Ok != pBitmap->LockBits( &aRect,
506 Gdiplus::ImageLockModeWrite | Gdiplus::ImageLockModeUserInputBuf,
507 PixelFormat32bppARGB,
508 &aBmpData ) )
510 return false;
513 // commit data to bitmap
514 pBitmap->UnlockBits( &aBmpData );
516 return drawGdiPlusBitmap( rGraphics,
517 pBitmap );
520 BitmapSharedPtr bitmapFromXBitmap( const uno::Reference< rendering::XBitmap >& xBitmap )
522 BitmapProvider* pBitmapProvider = dynamic_cast< BitmapProvider* >(xBitmap.get());
524 if( pBitmapProvider )
526 IBitmapSharedPtr pBitmap( pBitmapProvider->getBitmap() );
527 return pBitmap->getBitmap();
529 else
531 // not a native CanvasBitmap, extract VCL bitmap and
532 // render into GDI+ bitmap of similar size
533 // =================================================
535 const geometry::IntegerSize2D aBmpSize( xBitmap->getSize() );
536 BitmapSharedPtr pBitmap;
538 if( xBitmap->hasAlpha() )
540 // TODO(P2): At least for the alpha bitmap case, it
541 // would be possible to generate the corresponding
542 // bitmap directly
543 pBitmap.reset( new Gdiplus::Bitmap( aBmpSize.Width,
544 aBmpSize.Height,
545 PixelFormat32bppARGB ) );
547 else
549 // TODO(F2): Might be wise to create bitmap compatible
550 // to the VCL bitmap. Also, check whether the VCL
551 // bitmap's system handles can be used to create the
552 // GDI+ bitmap (currently, it does not seem so).
553 pBitmap.reset( new Gdiplus::Bitmap( aBmpSize.Width,
554 aBmpSize.Height,
555 PixelFormat24bppRGB ) );
558 GraphicsSharedPtr pGraphics(createGraphicsFromBitmap(pBitmap));
559 tools::setupGraphics(*pGraphics);
560 if( !drawVCLBitmapFromXBitmap(
561 pGraphics,
562 xBitmap) )
564 pBitmap.reset();
567 return pBitmap;
571 CanvasFont::ImplRef canvasFontFromXFont( const uno::Reference< rendering::XCanvasFont >& xFont )
573 CanvasFont* pCanvasFont = dynamic_cast< CanvasFont* >(xFont.get());
575 ENSURE_ARG_OR_THROW( pCanvasFont,
576 "canvasFontFromXFont(): Invalid XFont (or incompatible font for this XCanvas)" );
578 return CanvasFont::ImplRef( pCanvasFont );
581 void setModulateImageAttributes( Gdiplus::ImageAttributes& o_rAttr,
582 double nRedModulation,
583 double nGreenModulation,
584 double nBlueModulation,
585 double nAlphaModulation )
587 // This gets rather verbose, but we have to setup a color
588 // transformation matrix, in order to incorporate the global
589 // alpha value mfAlpha into the bitmap rendering.
590 Gdiplus::ColorMatrix aColorMatrix;
592 aColorMatrix.m[0][0] = static_cast<Gdiplus::REAL>(nRedModulation);
593 aColorMatrix.m[0][1] = 0.0;
594 aColorMatrix.m[0][2] = 0.0;
595 aColorMatrix.m[0][3] = 0.0;
596 aColorMatrix.m[0][4] = 0.0;
598 aColorMatrix.m[1][0] = 0.0;
599 aColorMatrix.m[1][1] = static_cast<Gdiplus::REAL>(nGreenModulation);
600 aColorMatrix.m[1][2] = 0.0;
601 aColorMatrix.m[1][3] = 0.0;
602 aColorMatrix.m[1][4] = 0.0;
604 aColorMatrix.m[2][0] = 0.0;
605 aColorMatrix.m[2][1] = 0.0;
606 aColorMatrix.m[2][2] = static_cast<Gdiplus::REAL>(nBlueModulation);
607 aColorMatrix.m[2][3] = 0.0;
608 aColorMatrix.m[2][4] = 0.0;
610 aColorMatrix.m[3][0] = 0.0;
611 aColorMatrix.m[3][1] = 0.0;
612 aColorMatrix.m[3][2] = 0.0;
613 aColorMatrix.m[3][3] = static_cast<Gdiplus::REAL>(nAlphaModulation);
614 aColorMatrix.m[3][4] = 0.0;
616 aColorMatrix.m[4][0] = 0.0;
617 aColorMatrix.m[4][1] = 0.0;
618 aColorMatrix.m[4][2] = 0.0;
619 aColorMatrix.m[4][3] = 0.0;
620 aColorMatrix.m[4][4] = 1.0;
622 o_rAttr.SetColorMatrix( &aColorMatrix,
623 Gdiplus::ColorMatrixFlagsDefault,
624 Gdiplus::ColorAdjustTypeDefault );
627 } // namespace tools
628 } // namespace dxcanvas