summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/png.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-04-29 12:11:08 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-04-29 12:11:08 +0200
commit16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (patch)
treee1b09d277dec2057e6b995ec099dd2b1f2129b35 /app/wlib/gtklib/png.c
parent09795a01ef859f072920de9df974d1b03b9ab9a4 (diff)
New upstream version 4.3.0upstream/4.3.0
Diffstat (limited to 'app/wlib/gtklib/png.c')
-rw-r--r--app/wlib/gtklib/png.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/app/wlib/gtklib/png.c b/app/wlib/gtklib/png.c
new file mode 100644
index 0000000..e11869e
--- /dev/null
+++ b/app/wlib/gtklib/png.c
@@ -0,0 +1,64 @@
+/** \file png.c
+ * PNG creation
+ */
+
+/* XTrackCad - Model Railroad CAD
+ * Copyright (C) 2015 Martin Fischer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#define GTK_DISABLE_SINGLE_INCLUDES
+#define GDK_DISABLE_DEPRECATED
+#define GTK_DISABLE_DEPRECATED
+#define GSEAL_ENABLE
+
+#include <gtk/gtk.h>
+#include "gtkint.h"
+
+#define BITMAPFILEFORMAT "png"
+
+/**
+* Export as bitmap file.
+*
+* \param d IN the drawing area ?
+* \param fileName IN fully qualified filename for the bitmap file.
+* \return TRUE on success, FALSE on error
+*/
+
+wBool_t wBitMapWriteFile(wDraw_p d, const char * fileName)
+{
+ GdkPixbuf *pixbuf;
+ GError *error;
+ gboolean res;
+ pixbuf = gdk_pixbuf_get_from_drawable(NULL, (GdkWindow*)d->pixmap, NULL, 0, 0,
+ 0, 0, d->w, d->h);
+
+ if (!pixbuf) {
+ wNoticeEx(NT_ERROR, "WriteBitMap: pixbuf_get failed", "Ok", NULL);
+ return FALSE;
+ }
+
+ error = NULL;
+ res = gdk_pixbuf_save(pixbuf, fileName, BITMAPFILEFORMAT, &error, NULL);
+
+ if (res == FALSE) {
+ wNoticeEx(NT_ERROR, "WriteBitMap: pixbuf_save failed", "Ok", NULL);
+ return FALSE;
+ }
+
+ g_object_unref(pixbuf);
+ return TRUE;
+}