diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-09-07 16:09:13 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-10-13 00:32:50 +0200 |
commit | ec44da9f5a2eeba8c9fa430158888c5aa8003ac9 (patch) | |
tree | 8a2911ce358dca344edf16932b7efe785c3ab486 | |
parent | 35b1688c92d2c0e1353fc2b5e89abb29c2acda8d (diff) |
quartz: Debug functionswip/quartz-debug
-rw-r--r-- | src/cairo-quartz-surface.c | 81 |
1 files changed, 5 insertions, 76 deletions
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index c86d913dd..9c44cec7e 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -135,7 +135,6 @@ static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE; #ifdef QUARTZ_DEBUG static void quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest); -static void quartz_image_to_png (CGImageRef, char *dest); #endif static cairo_quartz_surface_t * @@ -3001,73 +3000,11 @@ _cairo_surface_is_quartz (const cairo_surface_t *surface) #ifdef QUARTZ_DEBUG -#include <Movies.h> - -void ExportCGImageToPNGFile (CGImageRef inImageRef, char* dest) -{ - Handle dataRef = NULL; - OSType dataRefType; - CFStringRef inPath = CFStringCreateWithCString (NULL, dest, kCFStringEncodingASCII); - - GraphicsExportComponent grex = 0; - unsigned long sizeWritten; - - ComponentResult result; - - // create the data reference - result = QTNewDataReferenceFromFullPathCFString (inPath, kQTNativeDefaultPathStyle, - 0, &dataRef, &dataRefType); - - if (NULL != dataRef && noErr == result) { - // get the PNG exporter - result = OpenADefaultComponent (GraphicsExporterComponentType, kQTFileTypePNG, - &grex); - - if (grex) { - // tell the exporter where to find its source image - result = GraphicsExportSetInputCGImage (grex, inImageRef); - - if (noErr == result) { - // tell the exporter where to save the exporter image - result = GraphicsExportSetOutputDataReference (grex, dataRef, - dataRefType); - - if (noErr == result) { - // write the PNG file - result = GraphicsExportDoExport (grex, &sizeWritten); - } - } - - // remember to close the component - CloseComponent (grex); - } - - // remember to dispose of the data reference handle - DisposeHandle (dataRef); - } -} - -void -quartz_image_to_png (CGImageRef imgref, char *dest) -{ - static int sctr = 0; - char sptr[] = "/Users/vladimir/Desktop/barXXXXX.png"; - - if (dest == NULL) { - fprintf (stderr, "** Writing %p to bar%d\n", imgref, sctr); - sprintf (sptr, "/Users/vladimir/Desktop/bar%d.png", sctr); - sctr++; - dest = sptr; - } - - ExportCGImageToPNGFile (imgref, dest); -} - void quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest) { - static int sctr = 0; - char sptr[] = "/Users/vladimir/Desktop/fooXXXXX.png"; + static unsigned int sctr = 0; + char sptr[] = "cairo-quartz-debug-XXXXXXXXXXX.png"; if (nq->base.type != CAIRO_SURFACE_TYPE_QUARTZ) { fprintf (stderr, "** quartz_surface_to_png: surface %p isn't quartz!\n", nq); @@ -3075,21 +3012,13 @@ quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest) } if (dest == NULL) { - fprintf (stderr, "** Writing %p to foo%d\n", nq, sctr); - sprintf (sptr, "/Users/vladimir/Desktop/foo%d.png", sctr); + sprintf (sptr, "cairo-quartz-debug-%u.png", sctr); + fprintf (stderr, "** Writing %p to %s\n", nq, sptr); sctr++; dest = sptr; } - CGImageRef imgref = CGBitmapContextCreateImage (nq->cgContext); - if (imgref == NULL) { - fprintf (stderr, "quartz surface at %p is not a bitmap context!\n", nq); - return; - } - - ExportCGImageToPNGFile (imgref, dest); - - CGImageRelease (imgref); + cairo_surface_write_to_png (&nq->base, dest); } #endif /* QUARTZ_DEBUG */ |