mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-01 11:32:34 +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;
|
||||
|
||||
Reference in New Issue
Block a user