summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/writebitmap.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
commita14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (patch)
treee469179df67a0e0db49161a43cbf8076a189f6f4 /app/wlib/gtklib/writebitmap.c
parent5d2c2b27a6323e2666378b986129b2a7c2c39e5c (diff)
New upstream version 5.3.0GAupstream/5.3.0GAupstream
Diffstat (limited to 'app/wlib/gtklib/writebitmap.c')
-rw-r--r--app/wlib/gtklib/writebitmap.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/app/wlib/gtklib/writebitmap.c b/app/wlib/gtklib/writebitmap.c
index be9aa62..0f5041a 100644
--- a/app/wlib/gtklib/writebitmap.c
+++ b/app/wlib/gtklib/writebitmap.c
@@ -1,5 +1,5 @@
/** \file writebitmap.c
- * Bitmap file creation
+ * Bitmap file creation
*/
/* XTrackCad - Model Railroad CAD
@@ -17,7 +17,7 @@
*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define GTK_DISABLE_SINGLE_INCLUDES
@@ -34,21 +34,21 @@
/**
* Get the Extension part of a filename
- *
+ *
* /param fname the filename
- *
+ *
* /return char* point to the extension
*/
static const char *
GetExtension(const char *fname)
{
- const char *end = fname + strlen(fname);
+ const char *end = fname + strlen(fname);
- while (end > fname && *end != '.') {
- --end;
- }
- return( end + 1 );
+ while (end > fname && *end != '.') {
+ --end;
+ }
+ return( end + 1 );
}
/**
@@ -61,42 +61,42 @@ GetExtension(const char *fname)
wBool_t wBitMapWriteFile(wDraw_p d, const char * fileName)
{
- GdkPixbuf *pixbuf;
- GError *error;
- gboolean res;
- const char *fileFormat = GetExtension(fileName);
- char *writeFormat = NULL;
-
- if(!strcasecmp(fileFormat, PNGFORMAT )){
- writeFormat = PNGFORMAT;
- }
- if( !strcasecmp(fileFormat, "jpg") ||
- !strcasecmp(fileFormat, "jpeg")){
- writeFormat = JPEGFORMAT;
- }
-
- if(!writeFormat) {
- wNoticeEx(NT_ERROR, "WriteBitMap: invalid file format!", "Ok", NULL);
- return FALSE;
- }
-
- 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, writeFormat, &error, NULL);
-
- if (res == FALSE) {
- wNoticeEx(NT_ERROR, "WriteBitMap: pixbuf_save failed", "Ok", NULL);
- return FALSE;
- }
-
- g_object_ref_sink(pixbuf);
- g_object_unref(pixbuf);
- return TRUE;
+ GdkPixbuf *pixbuf;
+ GError *error;
+ gboolean res;
+ const char *fileFormat = GetExtension(fileName);
+ char *writeFormat = NULL;
+
+ if(!strcasecmp(fileFormat, PNGFORMAT )) {
+ writeFormat = PNGFORMAT;
+ }
+ if( !strcasecmp(fileFormat, "jpg") ||
+ !strcasecmp(fileFormat, "jpeg")) {
+ writeFormat = JPEGFORMAT;
+ }
+
+ if(!writeFormat) {
+ wNoticeEx(NT_ERROR, "WriteBitMap: invalid file format!", "Ok", NULL);
+ return FALSE;
+ }
+
+ 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, writeFormat, &error, NULL);
+
+ if (res == FALSE) {
+ wNoticeEx(NT_ERROR, "WriteBitMap: pixbuf_save failed", "Ok", NULL);
+ return FALSE;
+ }
+
+ g_object_ref_sink(pixbuf);
+ g_object_unref(pixbuf);
+ return TRUE;
}