GdkPixbufModuleSizeFunc size_func;
gpointer user_data;
- /* The "file" */
+ /* The SVG "file" that we're building in memory. */
char* svg_data;
- /* How far into the file are we? This should always point to the
+ /* How far into svg_data are we? This should always point to the
next empty byte. If (for example) svg_data_size is 2, then
svg_data[0] and svg_data[1] are used, but svg_data[2] is free. */
size_t svg_data_size;
switch ((int) path->path[j]) {
case svgtiny_PATH_MOVE:
cairo_move_to(cr,
- path->path[j + 1],
- path->path[j + 2]);
+ path->path[j + 1],
+ path->path[j + 2]);
j += 3;
break;
case svgtiny_PATH_CLOSE:
* svgtiny_free the result if it is valid.
*/
static diagram_t* svgtiny_diagram_from_buffer(char* buffer,
- size_t bytecount,
- int width,
- int height,
- GError** error) {
+ size_t bytecount,
+ int width,
+ int height,
+ GError** error) {
diagram_t* diagram;
svgtiny_code code;
crs = cairo_status(cr);
if (crs != CAIRO_STATUS_SUCCESS) {
fprintf(stderr,
- "cairo error: %s\n",
- cairo_status_to_string(crs));
+ "cairo error: %s\n",
+ cairo_status_to_string(crs));
cairo_destroy(cr);
return NULL;
}
* returned; if not, @c NULL is returned and @c error is populated.
*/
static GdkPixbuf* gdk_pixbuf_from_svg_buffer(char* buffer,
- size_t bytecount,
- GError** error) {
+ size_t bytecount,
+ GError** error) {
diagram_t* diagram;
cairo_t* cr = 0;
GdkPixbuf* pb;
GError* sub_error = NULL;
diagram = svgtiny_diagram_from_buffer(buffer,
- bytecount,
- VIEWPORT_WIDTH,
- VIEWPORT_HEIGHT,
- &sub_error);
+ bytecount,
+ VIEWPORT_WIDTH,
+ VIEWPORT_HEIGHT,
+ &sub_error);
if (!diagram) {
g_propagate_error(error, sub_error);
return NULL;
if (!cr) {
svgtiny_free(diagram);
g_set_error_literal(error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
- "could not create Cairo surface from SVG diagram");
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ "could not create Cairo surface from SVG diagram");
return NULL;
}
* So for now I'm back in the diagram camp.
*/
pb = gdk_pixbuf_get_from_surface(cairo_get_target(cr),
- 0,
- 0,
- diagram->width,
- diagram->height);
+ 0,
+ 0,
+ diagram->width,
+ diagram->height);
if (!pb) {
g_set_error_literal(error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_FAILED,
- "failed to obtain a GdkPixbuf from Cairo surface");
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_FAILED,
+ "failed to obtain a GdkPixbuf from Cairo surface");
}
return pb;
static gpointer gdk_pixbuf_begin_load(GdkPixbufModuleSizeFunc size_func,
- GdkPixbufModulePreparedFunc prep_func,
- GdkPixbufModuleUpdatedFunc updated_func,
- gpointer user_data,
- GError **error) {
+ GdkPixbufModulePreparedFunc prep_func,
+ GdkPixbufModuleUpdatedFunc updated_func,
+ gpointer user_data,
+ GError **error) {
SvgTinyContext* context = g_new(SvgTinyContext, 1);
static void emit_updated(SvgTinyContext* context, GdkPixbuf* pixbuf) {
if (context->updated_func != NULL) {
(*context->updated_func)(pixbuf,
- 0,
- 0,
- gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf),
- context->user_data);
+ 0,
+ 0,
+ gdk_pixbuf_get_width(pixbuf),
+ gdk_pixbuf_get_height(pixbuf),
+ context->user_data);
}
}
GError* sub_error = NULL;
pixbuf = gdk_pixbuf_from_svg_buffer(context->svg_data,
- context->svg_data_size,
- &sub_error);
+ context->svg_data_size,
+ &sub_error);
if (pixbuf != NULL) {
/*emit_size(context, pixbuf);*/