mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-04 21:04:18 +01:00
wrlib: merged both R*FlipImage function into one for the public API
It is generally not a good idea to have an API with a high number of functions because it adds complexity for user and for maintainability, so both function have been "merged" into a single RFlipImage with a parameter to specify what flip is expected. As a bonus, the function can perform both flips at once if wanted. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
cd29983e03
commit
654dcfeb28
31
wrlib/flip.c
31
wrlib/flip.c
@@ -29,8 +29,35 @@
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "wraster.h"
|
||||
#include "rotate.h"
|
||||
|
||||
RImage *RVerticalFlipImage(RImage *source)
|
||||
|
||||
static RImage *r_flip_vertically(RImage *source);
|
||||
static RImage *r_flip_horizontally(RImage *source);
|
||||
|
||||
/* Flip an image in the direction(s) specified */
|
||||
RImage *RFlipImage(RImage *source, int mode)
|
||||
{
|
||||
/* Security */
|
||||
if (source == NULL)
|
||||
return NULL;
|
||||
|
||||
switch (mode & (RVerticalFlip | RHorizontalFlip)) {
|
||||
case RHorizontalFlip:
|
||||
return r_flip_horizontally(source);
|
||||
|
||||
case RVerticalFlip:
|
||||
return r_flip_vertically(source);
|
||||
|
||||
case RHorizontalFlip | RVerticalFlip:
|
||||
return wraster_rotate_image_180(source);
|
||||
|
||||
default:
|
||||
return RRetainImage(source);
|
||||
}
|
||||
}
|
||||
|
||||
RImage *r_flip_vertically(RImage *source)
|
||||
{
|
||||
RImage *target;
|
||||
int nwidth, nheight;
|
||||
@@ -82,7 +109,7 @@ RImage *RVerticalFlipImage(RImage *source)
|
||||
return target;
|
||||
}
|
||||
|
||||
RImage *RHorizontalFlipImage(RImage *source)
|
||||
RImage *r_flip_horizontally(RImage *source)
|
||||
{
|
||||
RImage *target;
|
||||
int nwidth, nheight;
|
||||
|
||||
@@ -72,8 +72,7 @@ LIBWRASTER3
|
||||
RRetainImage;
|
||||
RRGBtoHSV;
|
||||
RRotateImage;
|
||||
RVerticalFlipImage;
|
||||
RHorizontalFlipImage;
|
||||
RFlipImage;
|
||||
RSaveImage;
|
||||
RScaleImage;
|
||||
RShutdown;
|
||||
|
||||
@@ -265,6 +265,14 @@ typedef enum {
|
||||
#define RGRD_DIAGONAL RDiagonalGradient
|
||||
|
||||
|
||||
/*
|
||||
* How an image can be flipped, for RFlipImage
|
||||
*
|
||||
* Values are actually bit-mask which can be OR'd
|
||||
*/
|
||||
#define RHorizontalFlip 0x0001
|
||||
#define RVerticalFlip 0x0002
|
||||
|
||||
|
||||
/* error codes */
|
||||
#define RERR_NONE 0
|
||||
@@ -366,9 +374,7 @@ RImage *RSmoothScaleImage(RImage *src, unsigned new_width,
|
||||
|
||||
RImage *RRotateImage(RImage *image, float angle);
|
||||
|
||||
RImage *RVerticalFlipImage(RImage *image);
|
||||
|
||||
RImage *RHorizontalFlipImage(RImage *image);
|
||||
RImage *RFlipImage(RImage *image, int mode);
|
||||
|
||||
RImage *RMakeTiledImage(RImage *tile, unsigned width, unsigned height);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user