1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

WRaster: add functions to save image on disk

This patch adds the RSaveTitledImage() function to the WRaster lib
to be able to save file on disk either as a PNG or a JPEG file.
Those two formats depends on optional external libs.
The function can take an optional title/comment which will
be save inside the file.

The WRaster lib and header versions are bumped.
This commit is contained in:
David Maciejak
2023-03-01 20:36:09 +08:00
committed by Carlos R. Mafra
parent 3cc5808dcd
commit c8883fdbb0
10 changed files with 286 additions and 16 deletions

View File

@@ -3,6 +3,7 @@
* Raster graphics library
*
* Copyright (c) 1998-2003 Alfredo K. Kojima
* Copyright (c) 2013-2023 Window Maker Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -29,18 +30,32 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
#include "wraster.h"
#include "imgformat.h"
#include "wr_i18n.h"
Bool RSaveImage(RImage * image, const char *filename, const char *format)
Bool RSaveImage(RImage *image, const char *filename, const char *format)
{
if (strcmp(format, "XPM") != 0) {
RErrorCode = RERR_BADFORMAT;
return False;
}
return RSaveXPM(image, filename);
return RSaveTitledImage(image, filename, format, NULL);
}
Bool RSaveTitledImage(RImage *image, const char *filename, const char *format, char *title)
{
#ifdef USE_PNG
if (strcasecmp(format, "PNG") == 0)
return RSavePNG(image, filename, title);
#endif
#ifdef USE_JPEG
if (strcasecmp(format, "JPG") == 0)
return RSaveJPEG(image, filename, title);
if (strcasecmp(format, "JPEG") == 0)
return RSaveJPEG(image, filename, title);
#endif
if (strcasecmp(format, "XPM") == 0)
return RSaveXPM(image, filename);
RErrorCode = RERR_BADFORMAT;
return False;
}