34 #include <cairo-svg.h> 35 #include <boost/pointer_cast.hpp> 61 unsigned int sliceWidth,
unsigned int sliceHeight);
86 unsigned int sliceWidth,
unsigned int sliceHeight);
105 static cairo_status_t
cairoWriter(
void* closure,
const unsigned char* data,
108 Tile::ImageType::element_type* b = (Tile::ImageType::element_type*) closure;
109 b->insert(b->end(), data, data+length);
110 return CAIRO_STATUS_SUCCESS;
119 unsigned int layerHeight,
120 unsigned int sliceWidth,
121 unsigned int sliceHeight)
123 for (
int i = 0; i < LAYER_NUM; i++)
125 layers[i].surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, layerWidth, layerHeight);
126 layers[i].cr = cairo_create(layers[i].surface);
129 slice.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, sliceWidth, sliceHeight);
130 slice.cr = cairo_create(slice.surface);
132 cairo_font_options_t* fontOpts = cairo_font_options_create();
133 cairo_font_options_set_hint_style(fontOpts, CAIRO_HINT_STYLE_NONE);
134 cairo_font_options_set_hint_metrics(fontOpts, CAIRO_HINT_METRICS_OFF);
135 cairo_set_font_options(layers[LAYER_LABELS].cr, fontOpts);
136 cairo_select_font_face(layers[LAYER_LABELS].cr,
DEFAULT_FONT,
137 CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
142 for (
int i = 0; i < LAYER_NUM; i++)
150 cairo_surface_flush(slice.surface);
151 Tile::ImageType buffer = boost::make_shared<Tile::ImageType::element_type>();
152 buffer->reserve(10*1024);
153 cairo_surface_write_to_png_stream(slice.surface,
cairoWriter, (
void*) buffer.get());
162 unsigned int layerHeight,
163 unsigned int sliceWidth,
164 unsigned int sliceHeight)
165 : buffer(
boost::make_shared<
Tile::ImageType::element_type>())
169 layers[i].
surface = cairo_svg_surface_create_for_stream(NULL, NULL, layerWidth, layerHeight);
174 (
void*)
buffer.get(), sliceWidth, sliceHeight);
179 CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
193 cairo_surface_flush(
layers[0].surface);
197 Tile::ImageType copiedBuffer = boost::make_shared<Tile::ImageType::element_type>(*buffer);
#define TILE_SIZE
This file is part of alaCarte.
virtual CairoLayer * getImageLayers()
Layers to paint the MetaTile onto.
cairo_surface_t * surface
This file is part of alaCarte.
virtual void clear()
Clears every layer. Should always be called before use.
virtual Tile::ImageType copySliceImage()
Returns the rendered slice.
virtual void clear()
Clears every layer. Should always be called before use.
virtual CairoLayer & getSliceLayer()
Get layer that is the size of a final tile for slicing.
virtual CairoLayer & getSliceLayer()
Get layer that is the size of a final tile for slicing.
CairoLayer layers[LAYER_NUM]
static cairo_status_t cairoWriter(void *closure, const unsigned char *data, unsigned int length)
Write function to capture the final PNG image.
virtual ~PNGRenderCanvas()=default
shared_ptr< std::vector< uint8_t > > ImageType
virtual Tile::ImageType copySliceImage()
Returns the rendered slice.
This file is part of alaCarte.
virtual CairoLayer * getImageLayers()
Layers to paint the MetaTile onto.
CairoLayer layers[LAYER_NUM]