-#include <stdio.h> /* fopen, fprintf, fread, printf */
+#include <stdio.h> /* fprintf, printf */
#include <string.h> /* memcpy */
#include <cairo.h>
}
-/**
- * @brief Create a GdkPixbuf from an SVG filestream.
- *
- * This is essentially a wrapper around @gdk_pixbuf_from_svg_buffer
- * that reads a @c FILE pointer into a buffer.
- *
- * @param fp
- * A pointer to a @c FILE containing the SVG document.
- *
- * @param error
- * The address of a @c GError pointer that we use to return errors.
- *
- * @return If successful, a valid pointer to a @c GdkPixbuf is
- * returned; if not, @c NULL is returned and @c error is populated.
- */
-static GdkPixbuf* gdk_pixbuf_from_svg_file_stream(FILE *fp, GError** error) {
- size_t bytecount, bytesread;
- char* buffer;
-
- /* Find the size of the file stream */
- fseek(fp, 0L, SEEK_END);
- bytecount = ftell(fp);
- rewind(fp);
-
- /* YOLO, no error checking */
- buffer = g_malloc(bytecount);
-
- bytesread = fread(buffer, 1, bytecount, fp);
- if (bytesread != bytecount) {
- g_set_error(error,
- G_FILE_ERROR,
- G_FILE_ERROR_FAILED,
- "read only %zd of %zd bytes from stream",
- bytesread,
- bytecount);
- return NULL;
- }
-
- return gdk_pixbuf_from_svg_buffer(buffer, bytecount, error);
-}
-
-
static gpointer gdk_pixbuf_begin_load(GdkPixbufModuleSizeFunc size_func,
GdkPixbufModulePreparedFunc prep_func,
GdkPixbufModuleUpdatedFunc updated_func,
module->begin_load = gdk_pixbuf_begin_load;
module->load_increment = gdk_pixbuf_load_increment;
module->stop_load = gdk_pixbuf_stop_load;
- module->load = gdk_pixbuf_from_svg_file_stream;
}
G_MODULE_EXPORT void fill_info(GdkPixbufFormat *info);
svgpath = argv[1];
pngpath = argv[2];
- fp = fopen(svgpath, "rb");
- if (!fp) {
- perror(svgpath);
- return 1;
- }
-
- pb = gdk_pixbuf_from_svg_file_stream(fp, &err);
+ pb = gdk_pixbuf_new_from_file(svgpath, &err);
if (!pb) {
fprintf(stderr,
- "Error %d in gdk_pixbuf_from_svg_file_stream: %s\n",
+ "Error %d in gdk_pixbuf_new_from_file: %s\n",
err->code,
err->message);
g_error_free(err);