From 2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 21 Nov 2011 08:44:10 +0000 Subject: Improve API to allow for RAM surfaces instead of direct blitting Improve and update tests Fix RAM surface Fix VNC surface svn path=/trunk/libnsfb/; revision=13158 --- src/dump.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/dump.c (limited to 'src/dump.c') diff --git a/src/dump.c b/src/dump.c new file mode 100644 index 0000000..ed56a00 --- /dev/null +++ b/src/dump.c @@ -0,0 +1,56 @@ +/* + * Copyright 2009 Vincent Sanders + * + * This file is part of libnsfb, http://www.netsurf-browser.org/ + * Licenced under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + */ + +#include +#include +#include +#include + +#include "libnsfb.h" +#include "libnsfb_plot.h" +#include "libnsfb_event.h" +#include "nsfb.h" +#include "surface.h" + +/* exported interface documented in libnsfb.h */ +bool +nsfb_dump(nsfb_t *nsfb, int fd) +{ + FILE *outf; + int x; + int y; + + outf = fdopen(dup(fd), "w"); + if (outf == NULL) { + return false; + } + + fprintf(outf,"P3\n#libnsfb buffer dump\n%d %d\n255\n", + nsfb->width, nsfb->height); + for (y=0; y < nsfb->height; y++) { + for (x=0; x < nsfb->width; x++) { + fprintf(outf,"%d %d %d ", + *(nsfb->ptr + (((nsfb->width * y) + x) * 4) + 2), + *(nsfb->ptr + (((nsfb->width * y) + x) * 4) + 1), + *(nsfb->ptr + (((nsfb->width * y) + x) * 4) + 0)); + + } + fprintf(outf,"\n"); + } + + fclose(outf); + + return true; +} + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ -- cgit v1.2.3