本文整理汇总了C++中agg::trans_affine类的典型用法代码示例。如果您正苦于以下问题:C++ trans_affine类的具体用法?C++ trans_affine怎么用?C++ trans_affine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了trans_affine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_raster_marker
void render_raster_marker(RendererType ren,
RasterizerType & ras,
image_data_rgba8 & src,
mapnik::feature_impl const& feature,
agg::trans_affine const& marker_tr,
double opacity)
{
using color_type = typename RendererType::color_type;
agg::scanline_bin sl;
double width = src.width();
double height = src.height();
double p[8];
p[0] = 0; p[1] = 0;
p[2] = width; p[3] = 0;
p[4] = width; p[5] = height;
p[6] = 0; p[7] = height;
marker_tr.transform(&p[0], &p[1]);
marker_tr.transform(&p[2], &p[3]);
marker_tr.transform(&p[4], &p[5]);
marker_tr.transform(&p[6], &p[7]);
ras.move_to_d(p[0],p[1]);
ras.line_to_d(p[2],p[3]);
ras.line_to_d(p[4],p[5]);
ras.line_to_d(p[6],p[7]);
ren.color(color_type(feature.id()));
agg::render_scanlines(ras, sl, ren);
}
示例2: init
box2d<T>::box2d(const box2d_type &rhs, const agg::trans_affine& tr)
{
double x0 = rhs.minx_, y0 = rhs.miny_;
double x1 = rhs.maxx_, y1 = rhs.miny_;
double x2 = rhs.maxx_, y2 = rhs.maxy_;
double x3 = rhs.minx_, y3 = rhs.maxy_;
tr.transform(&x0, &y0);
tr.transform(&x1, &y1);
tr.transform(&x2, &y2);
tr.transform(&x3, &y3);
init(x0, y0, x2, y2);
expand_to_include(x1, y1);
expand_to_include(x3, y3);
}
示例3: only_translation
bool only_translation(agg::trans_affine& mat, double epsilon)
{
double temp[6];
mat.store_to(temp);
return (f_eq(temp[0], 1.0) && f_eq(temp[1], 0.0) &&
f_eq(temp[2], 0.0) && f_eq(temp[3], 1.0));
}
示例4: get_translation
void get_translation(agg::trans_affine& m, double* tx, double* ty)
{
double temp[6];
m.store_to(temp);
*tx = temp[4];
*ty = temp[5];
}
示例5: add_image
void cairo_context::add_image(agg::trans_affine const& tr, image_rgba8 const& data, double opacity)
{
cairo_pattern pattern(data);
if (!tr.is_identity())
{
double m[6];
tr.store_to(m);
cairo_matrix_t cairo_matrix;
cairo_matrix_init(&cairo_matrix,m[0],m[1],m[2],m[3],m[4],m[5]);
cairo_matrix_invert(&cairo_matrix);
pattern.set_matrix(cairo_matrix);
}
cairo_save(cairo_.get());
cairo_set_source(cairo_.get(), const_cast<cairo_pattern_t*>(pattern.pattern()));
cairo_paint_with_alpha(cairo_.get(), opacity);
cairo_restore(cairo_.get());
check_object_status_and_throw_exception(*this);
}
示例6: get_scale
void get_scale(agg::trans_affine& m, double* dx, double* dy)
{
{
double temp[6];
m.store_to(temp);
*dx = temp[0];
*dy = temp[3];
}
}
示例7: trans_affine_compose
void
trans_affine_compose(agg::trans_affine& a, const agg::trans_affine& b)
{
double a_tx = a.tx, a_ty = a.ty;
a.premultiply(b);
a.tx = b.sx * a_tx + b.shx * a_ty + b.tx;
a.ty = b.shy * a_tx + b.sy * a_ty + b.ty;
}
示例8: is_identity
bool is_identity(agg::trans_affine& mat, double epsilon)
{
double temp[6];
mat.store_to(temp);
return (f_eq(temp[0], 1.0) && f_eq(temp[1], 0.0) &&
f_eq(temp[2], 0.0) && f_eq(temp[3], 1.0) &&
f_eq(temp[4], 0.0) && f_eq(temp[5], 0.0));
// return (temp[0] == 1.0 && temp[1] == 0.0 &&
// temp[2] == 0.0 && temp[3] == 1.0 &&
// temp[4] == 0.0 && temp[5] == 0.0);
}
示例9: render_raster_marker
void render_raster_marker(agg::trans_affine const& marker_tr)
{
double width = src_.width();
double height = src_.height();
double p[8];
p[0] = 0; p[1] = 0;
p[2] = width; p[3] = 0;
p[4] = width; p[5] = height;
p[6] = 0; p[7] = height;
marker_tr.transform(&p[0], &p[1]);
marker_tr.transform(&p[2], &p[3]);
marker_tr.transform(&p[4], &p[5]);
marker_tr.transform(&p[6], &p[7]);
ras_.move_to_d(p[0],p[1]);
ras_.line_to_d(p[2],p[3]);
ras_.line_to_d(p[4],p[5]);
ras_.line_to_d(p[6],p[7]);
RendererType ren(renb_);
ren.color(color_type(feature_.id()));
agg::render_scanlines(ras_, sl_, ren);
}
示例10: render_raster_marker
void render_raster_marker(agg::trans_affine const& marker_tr,
double opacity)
{
double width = src_.width();
double height = src_.height();
double p[8];
p[0] = 0; p[1] = 0;
p[2] = width; p[3] = 0;
p[4] = width; p[5] = height;
p[6] = 0; p[7] = height;
marker_tr.transform(&p[0], &p[1]);
marker_tr.transform(&p[2], &p[3]);
marker_tr.transform(&p[4], &p[5]);
marker_tr.transform(&p[6], &p[7]);
ras_.move_to_d(p[0],p[1]);
ras_.line_to_d(p[2],p[3]);
ras_.line_to_d(p[4],p[5]);
ras_.line_to_d(p[6],p[7]);
agg::span_allocator<color_type> sa;
agg::image_filter_bilinear filter_kernel;
agg::image_filter_lut filter(filter_kernel, false);
agg::rendering_buffer marker_buf((unsigned char *)src_.getBytes(),
src_.width(),
src_.height(),
src_.width()*4);
agg::pixfmt_rgba32_pre pixf(marker_buf);
typedef agg::image_accessor_clone<agg::pixfmt_rgba32_pre> img_accessor_type;
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
typedef agg::span_image_filter_rgba_2x2<img_accessor_type,
interpolator_type> span_gen_type;
typedef agg::renderer_scanline_aa_alpha<renderer_base,
agg::span_allocator<color_type>,
span_gen_type> renderer_type;
img_accessor_type ia(pixf);
interpolator_type interpolator(agg::trans_affine(p, 0, 0, width, height) );
span_gen_type sg(ia, interpolator, filter);
renderer_type rp(renb_,sa, sg, unsigned(opacity*255));
agg::render_scanlines(ras_, sl_, rp);
}
示例11: apply
void pathAttr::apply(agg::path_storage* path, const agg::trans_affine& tr, double accuracy)
{
double scale = sqrt(fabs(tr.determinant()));
if (mCommand == stroke) {
if (mIsoWidthFlag) {
trans.attach(*path);
trans.transformer(tr);
transCurvedStroked.width(mStrokeWidth * scale);
transCurvedStroked.line_join(mLineJoin);
transCurvedStroked.line_cap(mLineCap);
transCurvedStroked.miter_limit(mMiterLimit);
transCurvedStroked.inner_join(agg::inner_round);
transCurvedStroked.approximation_scale(accuracy);
transCurved.approximation_scale(accuracy);
// If the *visual* line width is considerable we
// turn on processing of curve cusps.
//---------------------
if (mStrokeWidth * scale > 1.0) {
transCurved.angle_tolerance(0.2);
} else {
transCurved.angle_tolerance(0.0);
}
} else {
curved.attach(*path);
curvedStrokedTrans.transformer(tr);
curvedStroked.width(mStrokeWidth);
curvedStroked.line_join(mLineJoin);
curvedStroked.line_cap(mLineCap);
curvedStroked.miter_limit(mMiterLimit);
curvedStroked.inner_join(agg::inner_round);
curvedStroked.approximation_scale(accuracy * scale);
curved.approximation_scale(accuracy * scale);
// If the *visual* line width is considerable we
// turn on processing of curve cusps.
//---------------------
if (mStrokeWidth * scale > 1.0) {
curved.angle_tolerance(0.2);
} else {
curved.angle_tolerance(0.0);
}
}
} else {
trans.attach(*path);
trans.transformer(tr);
transCurved.approximation_scale(accuracy);
}
}
示例12:
Bounds::Bounds(const agg::trans_affine& trans,
agg::path_storage* path, pathAttr* attr, double dilation,
double scale)
{
double centx = attr->mCentroid.x;
double centy = attr->mCentroid.y;
trans.transform(¢x, ¢y);
mValid = attr->boundingRect(path, trans, mMin_X, mMin_Y, mMax_X, mMax_Y, scale);
if (mValid && mMin_X <= centx && mMax_X >= centx &&
mMin_Y <= centy && mMax_Y >= centy && dilation != 1.0)
{
mMin_X = dilation * (mMin_X - centx) + centx;
mMax_X = dilation * (mMax_X - centx) + centx;
mMin_Y = dilation * (mMin_Y - centy) + centy;
mMax_Y = dilation * (mMax_Y - centy) + centy;
}
}
示例13: DrawImpl_rgb
void SelectionScanlineSweeper::DrawImpl_rgb(agg::rect_d rect, RenderingData *data, unsigned int width, unsigned int height, int stride,
agg::trans_affine const &mtx, agg::trans_affine const &viewport_mtx) {
//ScanlineSource source(data);
typedef agg::pixfmt_alpha_blend_rgb<agg::blender_rgb<agg::rgba8, agg::order_rgb>, agg::scanline_accessor> pixfmt_type;
typedef pixfmt_type::color_type color_type;
typedef color_type::value_type value_type;
typedef agg::renderer_base<pixfmt_type> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
agg::rasterizer_scanline_aa<> l_rasterizer;
agg::scanline_u8 l_scanline;
//pixfmt_type pixfmt(agg::scanline_accessor(&source, ScanlineSource::get_scanline, width, height, stride));
pixfmt_type pixfmt((agg::scanline_accessor(data)));
renderer_base rb(pixfmt);
l_rasterizer.clip_box(0.0, 0.0, width, height);
l_rasterizer.filling_rule(agg::fill_non_zero);
if (flip_y) {
mtx.transform(&rect.x1, &rect.y1);
mtx.transform(&rect.x2, &rect.y2);
}
double vertexes[] = {
rect.x1, rect.y2,
rect.x1, rect.y1,
rect.x2, rect.y1,
rect.x2, rect.y2
};
agg::test_vertex_source vertex_source(vertexes, 4);
agg::conv_transform<agg::test_vertex_source> vertex_source_converted(vertex_source, viewport_mtx);
l_rasterizer.add_path(vertex_source_converted);
renderer_solid r(rb);
{
r.color(color);
agg::render_scanlines(l_rasterizer, l_scanline, r);
}
}
示例14: pixf
unsigned CAggMemoryDC::DrawScaledText(
const TCHAR* text,
const GraphTypes::RectF& rc,
const GraphTypes::Color& clr,
const char* font,
int size,
const PointF & descsubtract)
{
if (m_buf==0)
return 0;
unsigned len=0;
pixel_format pixf(m_rbuf);
ren_base renb(pixf);
solid_renderer ren_solid(renb);
ATLASSERT(m_buf);
conv_font_curve_type fcurves(m_fonts->m_fman.path_adaptor());
conv_font_segm_type fsegm(fcurves);
conv_font_trans_type ftrans(fsegm, m_mtx);
// fsegm.approximation_scale(3.0);
// fcurves.approximation_scale(2.0);
m_fonts->m_feng.flip_y(true);
m_fonts->m_feng.hinting(true);
if(m_fonts->m_feng.create_font(
font,
agg::glyph_ren_outline,
size,
0.0,
FW_NORMAL,
false,
ANSI_CHARSET,
DEFAULT_PITCH | FF_SWISS
))
{
double x = 0.0;
double y = 0.0;
const TCHAR* p = text;
TEXTMETRIC tm;
GetTextMetrics(&tm);
//double descent=(tm.tmDescent>descsubtract.y)?(tm.tmDescent-descsubtract.y):(tm.tmDescent-1);
//ATLASSERT(tm.tmDescent>descsubtract.y);
//ATLASSERT(descent>0);
//descent *= m_mtx.scale();
//m_mtx *= agg::trans_affine_translation(rc.x-m_rcUpdate.left, rc.y+rc.Height-descent-m_rcUpdate.top);
double ascent=tm.tmAscent-descsubtract.y;
ATLASSERT(ascent>0.0f);
ascent *= m_mtx.scale();
m_mtx *= agg::trans_affine_translation(rc.x-m_rcUpdate.left, rc.y+ascent-m_rcUpdate.top);
ren_solid.color(agg::rgba8(clr.GetR(), clr.GetG(), clr.GetB(), clr.GetA()));
while(*p)
{
const agg::glyph_cache* glyph = m_fonts->m_fman.glyph(*p);
if(glyph)
{
m_fonts->m_fman.add_kerning(&x, &y);
m_fonts->m_fman.init_embedded_adaptors(glyph, x, y);
if(glyph->data_type == agg::glyph_data_outline)
{
m_ras_aa.add_path(ftrans);
}
// increment pen position
x += glyph->advance_x;
y += glyph->advance_y;
}
++p;
++len;
}
agg::render_scanlines(m_ras_aa, m_sl, ren_solid);
ATLASSERT(m_buf);
}
return len;
}
示例15: render_raster_marker
void render_raster_marker(agg::trans_affine const& marker_tr,
double opacity)
{
using pixfmt_pre = agg::pixfmt_rgba32_pre;
agg::scanline_u8 sl_;
double width = src_.width();
double height = src_.height();
if (std::fabs(1.0 - scale_factor_) < 0.001
&& (std::fabs(1.0 - marker_tr.sx) < agg::affine_epsilon)
&& (std::fabs(0.0 - marker_tr.shy) < agg::affine_epsilon)
&& (std::fabs(0.0 - marker_tr.shx) < agg::affine_epsilon)
&& (std::fabs(1.0 - marker_tr.sy) < agg::affine_epsilon))
{
agg::rendering_buffer src_buffer((unsigned char *)src_.getBytes(),src_.width(),src_.height(),src_.width() * 4);
pixfmt_pre pixf_mask(src_buffer);
if (snap_to_pixels_)
{
renb_.blend_from(pixf_mask,
0,
std::floor(marker_tr.tx + .5),
std::floor(marker_tr.ty + .5),
unsigned(255*opacity));
}
else
{
renb_.blend_from(pixf_mask,
0,
marker_tr.tx,
marker_tr.ty,
unsigned(255*opacity));
}
}
else
{
using img_accessor_type = agg::image_accessor_clone<pixfmt_pre>;
using interpolator_type = agg::span_interpolator_linear<>;
//using span_gen_type = agg::span_image_filter_rgba_2x2<img_accessor_type,interpolator_type>;
using span_gen_type = agg::span_image_resample_rgba_affine<img_accessor_type>;
using renderer_type = agg::renderer_scanline_aa_alpha<renderer_base,
agg::span_allocator<color_type>,
span_gen_type>;
double p[8];
p[0] = 0; p[1] = 0;
p[2] = width; p[3] = 0;
p[4] = width; p[5] = height;
p[6] = 0; p[7] = height;
marker_tr.transform(&p[0], &p[1]);
marker_tr.transform(&p[2], &p[3]);
marker_tr.transform(&p[4], &p[5]);
marker_tr.transform(&p[6], &p[7]);
agg::span_allocator<color_type> sa;
agg::image_filter_lut filter;
filter.calculate(agg::image_filter_bilinear(), true);
agg::rendering_buffer marker_buf((unsigned char *)src_.getBytes(),
src_.width(),
src_.height(),
src_.width()*4);
pixfmt_pre pixf(marker_buf);
img_accessor_type ia(pixf);
agg::trans_affine final_tr(p, 0, 0, width, height);
if (snap_to_pixels_)
{
final_tr.tx = std::floor(final_tr.tx+.5);
final_tr.ty = std::floor(final_tr.ty+.5);
}
interpolator_type interpolator(final_tr);
span_gen_type sg(ia, interpolator, filter);
renderer_type rp(renb_,sa, sg, unsigned(opacity*255));
ras_.move_to_d(p[0],p[1]);
ras_.line_to_d(p[2],p[3]);
ras_.line_to_d(p[4],p[5]);
ras_.line_to_d(p[6],p[7]);
agg::render_scanlines(ras_, sl_, rp);
}
}