[gimp] app: Add temp_buf_dump()
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] app: Add temp_buf_dump()
- Date: Fri, 14 Aug 2009 17:20:35 +0000 (UTC)
commit 1dbf732943497b4428862966b32911ef770debad
Author: Martin Nordholts <martinn src gnome org>
Date: Fri Aug 14 19:18:56 2009 +0200
app: Add temp_buf_dump()
Add temp_buf_dump() which can be used to dump TempBufs to disk for
easier analysis, for example with GIMP.
app/base/temp-buf.c | 29 +++++++++++++++++++++++++++++
app/base/temp-buf.h | 2 ++
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/app/base/temp-buf.c b/app/base/temp-buf.c
index aa9d1a3..ebc00c3 100644
--- a/app/base/temp-buf.c
+++ b/app/base/temp-buf.c
@@ -17,9 +17,14 @@
#include "config.h"
+#include <fcntl.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <glib-object.h>
+#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
@@ -439,6 +444,30 @@ temp_buf_get_memsize (TempBuf *buf)
}
+/**
+ * temp_buf_dump:
+ * @buf:
+ * @file:
+ *
+ * Dumps a TempBuf to a raw RGB image that is easy to analyze, for
+ * example with GIMP.
+ **/
+void
+temp_buf_dump (TempBuf *buf,
+ const gchar *filename)
+{
+ gint fd = g_open (filename, O_CREAT | O_TRUNC | O_WRONLY, 0666);
+
+ g_return_if_fail (fd != -1);
+ g_return_if_fail (buf != NULL);
+ g_return_if_fail (temp_buf_get_data (buf) != NULL);
+
+ write (fd, temp_buf_get_data (buf), temp_buf_get_data_size (buf));
+
+ close (fd);
+}
+
+
/* The conversion routines */
static void
diff --git a/app/base/temp-buf.h b/app/base/temp-buf.h
index fa42c51..a6f9b6b 100644
--- a/app/base/temp-buf.h
+++ b/app/base/temp-buf.h
@@ -70,6 +70,8 @@ gsize temp_buf_get_data_size (TempBuf *buf);
guchar * temp_buf_data_clear (TempBuf *buf);
gsize temp_buf_get_memsize (TempBuf *buf);
+void temp_buf_dump (TempBuf *buf,
+ const gchar *filename);
#endif /* __TEMP_BUF_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]