/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// not a known implementation object - try data source // interfaces
uno::Reference< rendering::XBezierPolyPolygon2D > xBezierPoly(
xPoly,
uno::UNO_QUERY );
// no implementation class and no data provider // found - contract violation.
ENSURE_ARG_OR_THROW( xLinePoly.is(), "VCLCanvas::polyPolygonFromXPolyPolygon2D(): Invalid input " "poly-polygon, cannot retrieve vertex data" );
namespace
{ // TODO(P2): Check whether this gets inlined. If not, make functor // out of it
Gdiplus::PointF implGdiPlusPointFromRealPoint2D( const css::geometry::RealPoint2D& rPoint )
{ return Gdiplus::PointF( static_cast<Gdiplus::REAL>(rPoint.X), static_cast<Gdiplus::REAL>(rPoint.Y) );
}
if( rPoly.areControlPointsUsed() )
{ // control points used -> for now, add all // segments as curves to GraphicsPath
// If the polygon is closed, we need to add the // first point, thus, one more (can't simply // GraphicsPath::CloseFigure() it, since the last // point cannot have any control points for GDI+)
rPoints.resize( 3*nPoints + (bClosedPolygon ? 1 : 0) );
if( bClosedPolygon )
{ // add first point again (to be able to pass // control points for the last point, see // above) const ::basegfx::B2DPoint& rPoint( rPoly.getB2DPoint(0) );
rPoints[nCurrOutput++] = Gdiplus::PointF( static_cast<Gdiplus::REAL>(rPoint.getX()), static_cast<Gdiplus::REAL>(rPoint.getY()) );
if(bNoLineJoin && nCurrOutput > 7)
{ for(sal_uInt32 a(3); a < nCurrOutput; a+=3)
{
rOutput->StartFigure();
rOutput->AddBezier(rPoints[a - 3], rPoints[a - 2], rPoints[a - 1], rPoints[a]);
}
} else
{
rOutput->AddBeziers( rPoints.data(), nCurrOutput );
}
} else
{ // GraphicsPath expects 3(n-1)+1 points (i.e. the // last point must not have any trailing control // points after it). // Therefore, simply don't pass the last two // points here. if( nCurrOutput > 3 )
{ if(bNoLineJoin && nCurrOutput > 7)
{ for(sal_uInt32 a(3); a < nCurrOutput; a+=3)
{
rOutput->StartFigure();
rOutput->AddBezier(rPoints[a - 3], rPoints[a - 2], rPoints[a - 1], rPoints[a]);
}
} else
{
rOutput->AddBeziers( rPoints.data(), nCurrOutput-2 );
}
}
}
} else
{ // no control points -> no curves, simply add // straight lines to GraphicsPath
rPoints.resize( nPoints );
uno::Sequence< sal_Int8 > argbToIntSequence( Gdiplus::ARGB rColor )
{ // TODO(F1): handle color space conversions, when defined on canvas/graphicDevice return
{ static_cast<sal_Int8>((rColor >> 16) & 0xFF), // red static_cast<sal_Int8>((rColor >> 8) & 0xFF), // green static_cast<sal_Int8>(rColor & 0xFF), // blue static_cast<sal_Int8>((rColor >> 24) & 0xFF) // alpha
};
}
Gdiplus::ARGB sequenceToArgb( const uno::Sequence< sal_Int8 >& rColor )
{
ENSURE_OR_THROW( rColor.getLength() > 2, "sequenceToArgb: need at least three channels" );
// TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
Gdiplus::ARGB aColor;
Gdiplus::ARGB sequenceToArgb( const uno::Sequence< double >& rColor )
{
ENSURE_OR_THROW( rColor.getLength() > 2, "sequenceToColor: need at least three channels" );
// TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
Gdiplus::ARGB aColor;
if( xBitmap->hasAlpha() )
{ // TODO(P2): At least for the alpha bitmap case, it // would be possible to generate the corresponding // bitmap directly
pBitmap = std::make_shared<Gdiplus::Bitmap>( aBmpSize.Width,
aBmpSize.Height,
PixelFormat32bppARGB );
} else
{ // TODO(F2): Might be wise to create bitmap compatible // to the VCL bitmap. Also, check whether the VCL // bitmap's system handles can be used to create the // GDI+ bitmap (currently, it does not seem so).
pBitmap = std::make_shared<Gdiplus::Bitmap>( aBmpSize.Width,
aBmpSize.Height,
PixelFormat24bppRGB );
}
ENSURE_ARG_OR_THROW( pCanvasFont, "canvasFontFromXFont(): Invalid XFont (or incompatible font for this XCanvas)" );
return CanvasFont::ImplRef( pCanvasFont );
}
void setModulateImageAttributes( Gdiplus::ImageAttributes& o_rAttr, double nRedModulation, double nGreenModulation, double nBlueModulation, double nAlphaModulation )
{ // This gets rather verbose, but we have to setup a color // transformation matrix, in order to incorporate the global // alpha value mfAlpha into the bitmap rendering.
Gdiplus::ColorMatrix aColorMatrix;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.