summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2005-05-16 11:41:42 +0000
committerKristian Høgsberg <krh@redhat.com>2005-05-16 11:41:42 +0000
commitea410111d38145e7c74558951b1d895ebaf6f8dc (patch)
tree34e2c3475ff5f501068bc440e435748a4fe1b9a6
parent60b0a05df73cef4a67d111a282b20ce1fd5081e6 (diff)
Take a filename instead of a FILE pointer.
-rw-r--r--ChangeLog7
-rw-r--r--src/cairo-output-stream.c20
-rw-r--r--src/cairo-pdf-surface.c24
-rw-r--r--src/cairo-pdf.h10
-rw-r--r--src/cairoint.h2
5 files changed, 41 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index c6defcdb..66889fc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-05-16 Kristian Høgsberg <krh@redhat.com>
+
+ * src/cairo-pdf-surface.c (cairo_pdf_surface_create):
+ * src/cairo-output-stream.c
+ (_cairo_output_stream_create_for_file): Take a filename instead of
+ a FILE pointer.
+
2005-05-14 Carl Worth <cworth@cworth.org>
* src/cairo-xcb.h:
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 5f6b73f6..e0b8e62d 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -266,12 +266,26 @@ stdio_write (void *closure, const unsigned char *data, unsigned int length)
static void
stdio_destroy_closure (void *closure)
{
+ FILE *fp = closure;
+
+ fclose (fp);
}
cairo_output_stream_t *
-_cairo_output_stream_create_for_file (FILE *fp)
+_cairo_output_stream_create_for_file (const char *filename)
{
- return _cairo_output_stream_create (stdio_write,
- stdio_destroy_closure, fp);
+ FILE *fp;
+ cairo_output_stream_t *stream;
+
+ fp = fopen (filename, "wb");
+ if (fp == NULL)
+ return NULL;
+
+ stream = _cairo_output_stream_create (stdio_write,
+ stdio_destroy_closure, fp);
+ if (stream == NULL)
+ fclose (fp);
+
+ return stream;
}
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index e3b47098..b09bfd81 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -160,8 +160,8 @@ struct cairo_pdf_document {
double width;
double height;
- double x_ppi;
- double y_ppi;
+ double x_dpi;
+ double y_dpi;
unsigned int next_available_id;
unsigned int pages_id;
@@ -190,7 +190,7 @@ struct cairo_pdf_surface {
cairo_array_t fonts;
};
-#define DEFAULT_PPI 300
+#define DEFAULT_DPI 300
static cairo_pdf_document_t *
_cairo_pdf_document_create (cairo_output_stream_t *stream,
@@ -939,13 +939,13 @@ cairo_pdf_surface_create_for_stream (cairo_write_func_t write,
}
cairo_surface_t *
-cairo_pdf_surface_create (FILE *fp,
+cairo_pdf_surface_create (const char *filename,
double width,
double height)
{
cairo_output_stream_t *stream;
- stream = _cairo_output_stream_create_for_file (fp);
+ stream = _cairo_output_stream_create_for_file (filename);
if (stream == NULL)
return NULL;
@@ -953,14 +953,14 @@ cairo_pdf_surface_create (FILE *fp,
}
void
-cairo_pdf_surface_set_ppi (cairo_surface_t *surface,
- double x_ppi,
- double y_ppi)
+cairo_pdf_surface_set_dpi (cairo_surface_t *surface,
+ double x_dpi,
+ double y_dpi)
{
cairo_pdf_surface_t *pdf_surface = (cairo_pdf_surface_t *) surface;
- pdf_surface->document->x_ppi = x_ppi;
- pdf_surface->document->y_ppi = y_ppi;
+ pdf_surface->document->x_dpi = x_dpi;
+ pdf_surface->document->y_dpi = y_dpi;
}
static cairo_surface_t *
@@ -1937,8 +1937,8 @@ _cairo_pdf_document_create (cairo_output_stream_t *output_stream,
document->finished = FALSE;
document->width = width;
document->height = height;
- document->x_ppi = DEFAULT_PPI;
- document->y_ppi = DEFAULT_PPI;
+ document->x_dpi = DEFAULT_DPI;
+ document->y_dpi = DEFAULT_DPI;
_cairo_array_init (&document->objects, sizeof (cairo_pdf_object_t));
_cairo_array_init (&document->pages, sizeof (unsigned int));
diff --git a/src/cairo-pdf.h b/src/cairo-pdf.h
index 3d622239..050e4aa7 100644
--- a/src/cairo-pdf.h
+++ b/src/cairo-pdf.h
@@ -41,12 +41,10 @@
#if CAIRO_HAS_PDF_SURFACE
-#include <stdio.h>
-
CAIRO_BEGIN_DECLS
cairo_surface_t *
-cairo_pdf_surface_create (FILE *fp,
+cairo_pdf_surface_create (const char *filename,
double width,
double height);
@@ -58,9 +56,9 @@ cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func,
double height);
void
-cairo_pdf_surface_set_ppi (cairo_surface_t *surface,
- double x_ppi,
- double y_ppi);
+cairo_pdf_surface_set_dpi (cairo_surface_t *surface,
+ double x_dpi,
+ double y_dpi);
CAIRO_END_DECLS
diff --git a/src/cairoint.h b/src/cairoint.h
index 78e92a41..5f71fb9b 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1798,7 +1798,7 @@ cairo_private cairo_status_t
_cairo_output_stream_get_status (cairo_output_stream_t *stream);
cairo_output_stream_t *
-_cairo_output_stream_create_for_file (FILE *fp);
+_cairo_output_stream_create_for_file (const char *filename);
/* Avoid unnecessary PLT entries. */