asflip(3x)
π asflip(3x) π
okay bestie, we're cracking open asflip(3x) from the AfterStep X11 window manager era of the manual pages, and no cap, this one is a whole tutorial situation. Let's get into it π¦
β¨ NAME β¨
asflip β demonstrates flipping image in 90 degree increments libAfterImage/tutorials/ASFlip
β¨ NAMEASFlip β¨
(yeah, they really put a second NAME section in here, iconic behavior, we're keeping it π )
β¨ SYNOPSIS β¨
libAfterImage application for image rotation.
β¨ DESCRIPTION β¨
So the new steps this tutorial is gonna walk you through are literally these two:
- ASFlip.1. Flip value.
- ASFlip.2. Rotating
ASImage.
That's it. That's the whole lesson. Rotate the image, girl. π₯
β¨ SEE ALSO β¨
- Tutorial 1:
ASViewβ explanation of basic steps needed to uselibAfterImageand some other simple things. - Tutorial 2:
ASScaleβ image scaling basics. - Tutorial 3:
ASTileβ image tiling and tinting. - Tutorial 4:
ASMergeβ scaling and blending of arbitrary number of images. - Tutorial 5:
ASGradβ drawing multipoint linear gradients.
β¨ SOURCE β¨
here's the whole thing, and yes, it's a lot. grab a snack π
#include "../afterbase.h" #include "../afterimage.h" #include
"common.h"
void usage() {
printf( "Usage: asflip [-h]|[[-f flip]|[-m vertical] "
"[-g geom] image]");
printf( "\nWhere: image - is image filename\n");
printf( " flip - rotation angle in degrees. "
"90, 180 and 270 degrees supported\n");
printf( " geom - source image is tiled using this
geometry, "
"prior to rotation\n");
printf( " vertical - 1 - mirror image in vertical
direction, "
"0 - horizontal\n"); }
int main(int argc, char* argv[]) {
Display *dpy = NULL;
ASVisual *asv ;
int screen = 0 , depth = 0 ;
char *image_file = "rose512.jpg" ;
int flip = FLIP_VERTICAL;
Bool vertical = False, mirror = False ;
int tile_x, tile_y, geom_flags = 0;
unsigned int tile_width, tile_height ;
ASImage *im = NULL;
ASImage *flipped_im = NULL ;
/* see ASView.1 : */
set_application_name( argv[0] );
if( argc > 1 )
{
int i = 1 ;
if( strcmp( argv[1], "-h" ) == 0 )
{
usage();
return 0;
}
for( i = 1 ; i < argc ; i++ )
{
if( argv[i][0] == '-' && i < argc-1 )
{
switch(argv[i][1])
{
case 'm' :
mirror = True;
vertical = atoi(argv[i+1]) ;
break ;
case 'f' : /* see ASFlip.1 */
mirror = False;
flip = atoi(argv[i+1])/90 ;
break ;
case 'g' : /* see ASTile.2 : */
geom_flags = XParseGeometry( argv[i+1],
&tile_x,
&tile_y,
&tile_width,
&tile_height );
break ;
}
++i ;
}else
image_file = argv[i] ;
}
}else
usage();
#ifndef X_DISPLAY_MISSING
dpy = XOpenDisplay(NULL);
_XA_WM_DELETE_WINDOW = XInternAtom( dpy, "WM_DELETE_WINDOW",
False);
screen = DefaultScreen(dpy);
depth = DefaultDepth( dpy, screen ); #endif
/* see ASView.2 : */
im = file2ASImage( image_file, 0xFFFFFFFF, SCREEN_GAMMA, 0,
getenv("IMAGE_PATH"), NULL );
if( im == NULL )
return 1;
/* Making sure tiling geometry is sane : */
if( !get_flags(geom_flags, XValue ) )
tile_x = 0 ;
if( !get_flags(geom_flags, YValue ) )
tile_y = 0 ;
if( !get_flags(geom_flags, WidthValue ) )
{
if( !mirror )
tile_width = (get_flags(flip,FLIP_VERTICAL))?
im->height:im->width ;
else
tile_width = im->width ;
}
if( !get_flags(geom_flags, HeightValue ) )
{
if( !mirror )
tile_height = (get_flags(flip,FLIP_VERTICAL))?
im->width:im->height;
else
tile_height = im->height ;
}
printf( "%s: tiling image \"%s\" to %dx%d%+d%+d and then "
"flipping it by %d degrees\n",
get_application_name(), image_file,
tile_width, tile_height,tile_x, tile_y, flip*90 );
/* see ASView.3 : */
asv = create_asvisual( dpy, screen, depth, NULL );
/* see ASFlip.2 : */
if( !mirror )
flipped_im = flip_asimage( asv, im,
tile_x, tile_y,
tile_width, tile_height,
flip,
ASA_ASImage, 0,
ASIMAGE_QUALITY_DEFAULT );
else
flipped_im = mirror_asimage(asv, im,
tile_x, tile_y,
tile_width, tile_height,
vertical,
ASA_ASImage, 0,
ASIMAGE_QUALITY_DEFAULT );
destroy_asimage( &im );
if( flipped_im )
{ #ifndef X_DISPLAY_MISSING
/* see ASView.4 : */
Window w = create_top_level_window( asv,
DefaultRootWindow(dpy),
32, 32,
tile_width, tile_height,
1, 0, NULL,
"ASFlip", image_file );
if( w != None )
{
Pixmap p ;
XMapRaised (dpy, w);
/* see ASView.5 : */
p = asimage2pixmap( asv, DefaultRootWindow(dpy),
flipped_im,
NULL, True );
destroy_asimage( &flipped_im );
/* see common.c: set_window_background_and_free() : */
p = set_window_background_and_free( w, p );
/* see common.c: wait_closedown() : */
}
wait_closedown(w);
dpy = NULL; #else
/* writing result into the file */
ASImage2file( flipped_im, NULL, "asflip.jpg", ASIT_Jpeg,
NULL );
destroy_asimage( &flipped_im ); #endif
}
return 0 ; }
libAfterImage/tutorials/ASFlip.1 [6.1]
β¨ SYNOPSIS β¨
Step 1. Flip value.
β¨ DESCRIPTION β¨
so libAfterImage has this whole facility for rotating images in 90 degree increments β which is basically flipping, fr fr. and because of that, the flip parameter can only have 4 values: 0, -90, -180, -270 degrees. that's the vibe check on the whole thing π
β¨ EXAMPLE β¨
flip = atoi(argv[2])/90;
β¨ SEE ALSO β¨
flip
libAfterImage/tutorials/ASFlip.2 [6.2]
β¨ SYNOPSIS β¨
Step 2. Flipping ASImage.
β¨ DESCRIPTION β¨
bestie, flipping can actually be combined with offset and tiling. so here's the tea: the original image gets tiled to the supplied rectangle, and then it gets rotated to the requested degree. two-step glow-up π₯
β¨ EXAMPLE β¨
flipped_im = flip_asimage(asv, im,
tile_x, tile_y,
tile_width, tile_height,
flip,
ASA_XImage,0,
ASIMAGE_QUALITY_DEFAULT );
destroy_asimage( &im );
β¨ NOTES β¨
since we need to render the rotated image right away, we set the to_xim parameter to True, so that the image will be rotated into an XImage. and the second rotation is done β boom β we can destroy the original image. efficient queen behavior π
β¨ SEE ALSO β¨
flip_asimage()
and that's a wrap, pookie π«Ά this whole page came to you from the 3rd Berkeley Distribution, AfterStep v.2.2.12, filed under asflip(3x). go rotate something pretty πβ¨
π¦ where this page comes from
- ubuntu resolute: libafterimage-dev 2.2.12-19 Β· GPL-2.0-or-later
- ubuntu stonking: libafterimage-dev 2.2.12-19 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms