-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGDIPlusRenderer.cpp
46 lines (35 loc) · 1.32 KB
/
GDIPlusRenderer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//---------------------------------------------------------------------------
#pragma hdrstop
#include <algorithm>
#include <Vcl.Graphics.hpp>
#include "IModel.h"
#include "GDIPlusRenderer.h"
#include "Utils.h"
using std::transform;
//---------------------------------------------------------------------------
#pragma package(smart_init)
namespace AreaPrj {
void GDIPlusRenderer::DoPrepareRendering( IModel const & Model )
{
auto& Polygons = Model.GetPolygons();
PolygonCont GdiPolygons;
for ( auto const & Pol : Polygons ) {
GdiPolygons.push_back( ToGDIPolygon<Polygon>( Pol.outer() ) );
for ( auto const & RingInner : Pol.inners() ) {
GdiPolygons.push_back( ToGDIPolygon<Polygon>( RingInner ) );
}
}
polygons_ = std::move( GdiPolygons );
}
//---------------------------------------------------------------------------
void GDIPlusRenderer::DoRender( Vcl::Graphics::TCanvas& Canvas ) const
{
Gdiplus::Graphics g( Canvas.Handle );
Gdiplus::Pen MPen( Gdiplus::Color( 0xFF, 0, 0, 0 ) );
g.SetSmoothingMode( Gdiplus::SmoothingModeAntiAlias );
for ( auto const & Polygon : polygons_ ) {
g.DrawPolygon( &MPen, Polygon.data(), Polygon.size() );
}
}
//---------------------------------------------------------------------------
} // End of namespace AreaPrj