本文整理汇总了C++中CAIRO_RENDERER函数的典型用法代码示例。如果您正苦于以下问题:C++ CAIRO_RENDERER函数的具体用法?C++ CAIRO_RENDERER怎么用?C++ CAIRO_RENDERER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CAIRO_RENDERER函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderTileCairo
int renderTileCairo(imageObj *img, imageObj *tile, double x, double y) {
cairo_renderer *r = CAIRO_RENDERER(img);
cairo_surface_t *im = CAIRO_RENDERER(tile)->surface;
int w = cairo_image_surface_get_width (im);
int h = cairo_image_surface_get_height (im);
cairo_save(r->cr);
cairo_translate(r->cr, MS_NINT(x-0.5 * w), MS_NINT(y -0.5 * h));
cairo_set_source_surface(r->cr, im, 0, 0);
cairo_pattern_set_filter (cairo_get_source (r->cr), CAIRO_FILTER_NEAREST);
cairo_paint(r->cr);
cairo_restore(r->cr);
return MS_SUCCESS;
}
示例2: mergeRasterBufferCairo
int mergeRasterBufferCairo(imageObj *img, rasterBufferObj *rb, double opacity,
int srcX, int srcY, int dstX, int dstY,
int width, int height)
{
cairo_surface_t *src;
cairo_renderer *r;
/* not implemented for src,dst,width and height */
if(rb->type != MS_BUFFER_BYTE_RGBA) {
return MS_FAILURE;
}
r = CAIRO_RENDERER(img);
src = cairo_image_surface_create_for_data(rb->data.rgba.pixels,CAIRO_FORMAT_ARGB32,
rb->width,rb->height,
rb->data.rgba.row_step);
if(dstX||dstY||srcX||srcY||width!=img->width||height!=img->height) {
cairo_set_source_surface (r->cr, src, dstX - srcX, dstY - srcY);
cairo_rectangle (r->cr, dstX, dstY, width, height);
cairo_fill (r->cr);
} else {
cairo_set_source_surface (r->cr,src,0,0);
cairo_paint_with_alpha(r->cr,opacity);
}
cairo_surface_finish(src);
cairo_surface_destroy(src);
return MS_SUCCESS;
}
示例3: renderPixmapSymbolCairo
int renderPixmapSymbolCairo(imageObj *img, double x, double y,symbolObj *symbol,
symbolStyleObj *style)
{
cairo_renderer *r = CAIRO_RENDERER(img);
cairo_surface_t *im;
rasterBufferObj *b = symbol->pixmap_buffer;
assert(b);
if(!symbol->renderer_cache) {
symbol->renderer_cache = (void*)createSurfaceFromBuffer(b);
}
assert(symbol->renderer_cache);
im=(cairo_surface_t*)symbol->renderer_cache;
cairo_save(r->cr);
if(style->rotation != 0 || style->scale != 1) {
cairo_translate (r->cr, x,y);
cairo_rotate (r->cr, -style->rotation);
cairo_scale (r->cr, style->scale,style->scale);
cairo_translate (r->cr, -0.5*b->width, -0.5*b->height);
} else {
cairo_translate (r->cr, MS_NINT(x-0.5*b->width),MS_NINT(y-0.5*b->height));
}
cairo_set_source_surface (r->cr, im, 0, 0);
cairo_paint (r->cr);
cairo_restore(r->cr);
return MS_SUCCESS;
}
示例4: renderEllipseSymbolCairo
int renderEllipseSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol,
symbolStyleObj *style)
{
cairo_renderer *r = CAIRO_RENDERER(img);
cairo_save(r->cr);
cairo_set_line_cap(r->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(r->cr, CAIRO_LINE_JOIN_MITER);
cairo_translate(r->cr,x,y);
cairo_rotate(r->cr,-style->rotation);
cairo_scale(r->cr,symbol->sizex*style->scale/2,symbol->sizey*style->scale/2);
cairo_arc (r->cr, 0,0,1, 0, 2 * MS_PI);
cairo_restore(r->cr);
if(style->color) {
msCairoSetSourceColor(r->cr, style->color);
cairo_fill_preserve(r->cr);
}
if(style->outlinewidth > 0) {
cairo_set_line_width (r->cr, style->outlinewidth);
msCairoSetSourceColor(r->cr, style->outlinecolor);
cairo_stroke_preserve(r->cr);
}
cairo_new_path(r->cr);
return MS_SUCCESS;
}
示例5: renderLineCairo
int renderLineCairo(imageObj *img, shapeObj *p, strokeStyleObj *stroke) {
int i,j;
cairo_renderer *r = CAIRO_RENDERER(img);
assert(stroke->color);
cairo_new_path(r->cr);
msCairoSetSourceColor(r->cr,stroke->color);
for(i=0;i<p->numlines;i++) {
lineObj *l = &(p->line[i]);
cairo_move_to(r->cr,l->point[0].x,l->point[0].y);
for(j=1;j<l->numpoints;j++) {
cairo_line_to(r->cr,l->point[j].x,l->point[j].y);
}
}
if(stroke->patternlength>0) {
cairo_set_dash(r->cr,stroke->pattern,stroke->patternlength,0);
}
switch(stroke->linecap) {
case MS_CJC_BUTT:
cairo_set_line_cap(r->cr,CAIRO_LINE_CAP_BUTT);
break;
case MS_CJC_SQUARE:
cairo_set_line_cap(r->cr,CAIRO_LINE_CAP_SQUARE);
break;
case MS_CJC_ROUND:
case MS_CJC_NONE:
default:
cairo_set_line_cap(r->cr,CAIRO_LINE_CAP_ROUND);
}
cairo_set_line_width (r->cr, stroke->width);
cairo_stroke (r->cr);
if(stroke->patternlength>0) {
cairo_set_dash(r->cr,stroke->pattern,0,0);
}
return MS_SUCCESS;
}
示例6: renderSVGSymbolCairo
int renderSVGSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol,
symbolStyleObj *style)
{
#ifdef USE_SVG_CAIRO
cairo_renderer *r = CAIRO_RENDERER(img);
//double ox=symbol->sizex*0.5,oy=symbol->sizey*0.5;
svg_cairo_status_t status;
struct svg_symbol_cache *cache;
msPreloadSVGSymbol(symbol);
assert(symbol->renderer_cache);
cache = symbol->renderer_cache;
cairo_save(r->cr);
cairo_translate(r->cr,x,y);
cairo_scale(r->cr,style->scale,style->scale);
if (style->rotation != 0) {
cairo_rotate(r->cr, -style->rotation);
cairo_translate (r->cr, -(int)(symbol->sizex/2), -(int)(symbol->sizey/2));
} else
cairo_translate (r->cr, -(int)(symbol->sizex/2), -(int)(symbol->sizey/2));
status = svg_cairo_render(cache->svgc, r->cr);
cairo_restore(r->cr);
return MS_SUCCESS;
#else
msSetError(MS_MISCERR, "SVG Symbols requested but is not built with libsvgcairo",
"renderSVGSymbolCairo()");
return MS_FAILURE;
#endif
}
示例7: startLayerVectorCairo
int startLayerVectorCairo(imageObj *img, mapObj *map, layerObj *layer)
{
if(layer->compositer && layer->compositer->opacity<100) {
cairo_renderer *r = CAIRO_RENDERER(img);
cairo_push_group (r->cr);
}
return MS_SUCCESS;
}
示例8: renderTruetypeSymbolCairo
int renderTruetypeSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol,
symbolStyleObj *s)
{
int unicode;
cairo_glyph_t glyph;
cairo_text_extents_t extents;
cairo_matrix_t trans;
double ox,oy;
cairoCacheData *cache = MS_IMAGE_RENDERER_CACHE(img);
cairo_renderer *r = CAIRO_RENDERER(img);
faceCacheObj *face = getFontFace(cache,symbol->full_font_path);
if(!face) return MS_FAILURE;
cairo_save(r->cr);
cairo_set_font_face(r->cr,face->face);
cairo_set_font_size(r->cr,s->scale*96/72.0);
msUTF8ToUniChar(symbol->character, &unicode);
if (face->ftface->charmap &&
face->ftface->charmap->encoding == FT_ENCODING_MS_SYMBOL)
unicode |= 0xf000;
glyph.index = FT_Get_Char_Index(face->ftface, unicode);
glyph.x=0;
glyph.y=0;
cairo_glyph_extents(r->cr,&glyph,1,&extents);
ox=extents.x_bearing+extents.width/2.;
oy=extents.y_bearing+extents.height/2.;
cairo_matrix_init_rotate(&trans,-s->rotation);
cairo_matrix_transform_point(&trans,&ox,&oy);
/* cairo_translate(cr,-extents.width/2,-extents.height/2); */
cairo_translate(r->cr,x-ox,y-oy);
cairo_rotate(r->cr, -s->rotation);
cairo_glyph_path(r->cr,&glyph,1);
if (s->outlinewidth) {
msCairoSetSourceColor(r->cr, s->outlinecolor);
cairo_set_line_width(r->cr, s->outlinewidth + 1);
cairo_stroke_preserve(r->cr);
}
if(s->color) {
msCairoSetSourceColor(r->cr, s->color);
cairo_fill_preserve(r->cr);
}
cairo_new_path(r->cr);
cairo_restore(r->cr);
return MS_SUCCESS;
}
示例9: renderSVGSymbolCairo
int renderSVGSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol,
symbolStyleObj *style) {
#ifdef USE_SVG_CAIRO
cairo_renderer *r = CAIRO_RENDERER(img);
//double ox=symbol->sizex*0.5,oy=symbol->sizey*0.5;
unsigned int svg_width, svg_height;
svg_cairo_status_t status;
svg_cairo_t *svgc;
double scale;
//use cache for svg surface
if(!symbol->renderer_cache) {
status = svg_cairo_create(&svgc);
status = svg_cairo_parse_buffer(svgc, symbol->svg_text, strlen(symbol->svg_text));
if (status) {
msSetError(MS_RENDERERERR, "problem creating cairo svg", "renderSVGSymbolCairo()");
return MS_FAILURE;
}
symbol->renderer_cache = svgc;
}
assert(symbol->renderer_cache);
svgc=(svg_cairo_t *)symbol->renderer_cache;
svg_cairo_get_size (svgc, &svg_width, &svg_height);
//scale such that the SVG is rendered at the desired size in pixels
scale = style->scale;
/*
if (style->scale != 1) {
scale = MS_MIN(style->scale / (double) svg_width,
style->scale / (double) svg_height);
} else {
scale = style->scale;
}
*/
cairo_save(r->cr);
cairo_translate(r->cr,x,y);
cairo_scale(r->cr,scale,scale);
if (style->rotation != 0) {
cairo_rotate(r->cr, -style->rotation);
cairo_translate (r->cr, -(int)svg_width/2, -(int)svg_height/2);
}
else
cairo_translate (r->cr, -(int)svg_width/2, -(int)svg_height/2);
status = svg_cairo_render(svgc, r->cr);
cairo_restore(r->cr);
return MS_SUCCESS;
#else
msSetError(MS_MISCERR, "SVG Symbols requested but is not built with libsvgcairo",
"renderSVGSymbolCairo()");
return MS_FAILURE;
#endif
}
示例10: closeLayerVectorCairo
int closeLayerVectorCairo(imageObj *img, mapObj *map, layerObj *layer)
{
if(layer->compositer && layer->compositer->opacity<100) {
cairo_renderer *r = CAIRO_RENDERER(img);
cairo_pop_group_to_source (r->cr);
cairo_paint_with_alpha (r->cr, layer->compositer->opacity*0.01);
}
return MS_SUCCESS;
}
示例11: saveImageCairo
int saveImageCairo(imageObj *img, FILE *fp, outputFormatObj *format) {
cairo_renderer *r = CAIRO_RENDERER(img);
if(!strcasecmp(img->format->driver,"cairo/pdf") || !strcasecmp(img->format->driver,"cairo/svg")) {
cairo_surface_finish (r->surface);
fwrite(r->outputStream->data,r->outputStream->size,1,fp);
} else {
// not supported
}
return MS_SUCCESS;
}
示例12: renderPolygonTiledCairo
int renderPolygonTiledCairo(imageObj *img, shapeObj *p, imageObj *tile) {
int i,j;
cairo_renderer *r = CAIRO_RENDERER(img);
cairo_renderer *tileRenderer = CAIRO_RENDERER(tile);
cairo_pattern_t *pattern = cairo_pattern_create_for_surface(tileRenderer->surface);
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source(r->cr, pattern);
for (i = 0; i < p->numlines; i++) {
lineObj *l = &(p->line[i]);
cairo_move_to(r->cr, l->point[0].x, l->point[0].y);
for (j = 1; j < l->numpoints; j++) {
cairo_line_to(r->cr, l->point[j].x, l->point[j].y);
}
//cairo_close_path(r->cr);
}
cairo_fill(r->cr);
cairo_pattern_destroy(pattern);
return MS_SUCCESS;
}
示例13: saveImageBufferCairo
unsigned char* saveImageBufferCairo(imageObj *img, int *size_ptr, outputFormatObj *format)
{
cairo_renderer *r = CAIRO_RENDERER(img);
unsigned char *data;
assert(!strcasecmp(img->format->driver,"cairo/pdf") || !strcasecmp(img->format->driver,"cairo/svg"));
cairo_surface_finish (r->surface);
data = msSmallMalloc(r->outputStream->size);
memcpy(data,r->outputStream->data,r->outputStream->size);
*size_ptr = (int)r->outputStream->size;
return data;
}
示例14: cairo_renderer_finalize
static void
cairo_renderer_finalize (PinPointRenderer *pp_renderer)
{
CairoRenderer *renderer = CAIRO_RENDERER (pp_renderer);
g_free (renderer->path);
if (renderer->surface)
cairo_surface_destroy (renderer->surface);
g_hash_table_unref (renderer->surfaces);
g_hash_table_unref (renderer->svgs);
if (renderer->ctx)
cairo_destroy (renderer->ctx);
}
示例15: freeImageCairo
int freeImageCairo(imageObj *img) {
cairo_renderer *r = CAIRO_RENDERER(img);
if(r) {
cairo_destroy(r->cr);
cairo_surface_finish(r->surface);
cairo_surface_destroy(r->surface);
if(r->outputStream) {
msBufferFree(r->outputStream);
free(r->outputStream);
}
free(r);
}
return MS_SUCCESS;
}