BRL-CAD
rot.c File Reference
#include "common.h"
#include <stdlib.h>
#include <string.h>
#include "bio.h"
#include "bu/str.h"
#include "bu/log.h"
#include "bu/file.h"
#include "bu/getopt.h"
#include "bu/malloc.h"
#include "bn.h"
Include dependency graph for rot.c:

Go to the source code of this file.

Macros

#define DtoR(x)   ((x)*DEG2RAD)
 

Functions

int get_args (int argc, char **argv, FILE **ifp, FILE **ofp, double *angle)
 
int icv_rot (int argc, char **argv)
 

Variables

ssize_t buflines
 
ssize_t scanbytes
 
ssize_t firsty = -1
 
ssize_t lasty = -1
 
unsigned char * bp
 
unsigned char * obp
 
ssize_t nxin = 512
 
ssize_t nyin = 512
 
ssize_t yin
 
ssize_t xout
 
ssize_t yout
 
int plus90
 
int minus90
 
int reverse
 
int invert
 
size_t pixbytes = 1
 

Detailed Description

Rotate, Invert, and/or Reverse the pixels in an image file.

The rotation logic was worked out for data ordered with "upper left" first. It is being used on files in first quadrant order (lower left first). Thus the "forward", "backward" flags are reversed.

The code was designed to never need to seek on the input, while it may need to seek on output (if the max buffer is too small). It would be nice if we could handle the reverse case also (e.g. pipe on stdout).

Note that this program can be applied to any collection of interleaved channel byte entities.

Definition in file rot.c.

Macro Definition Documentation

#define DtoR (   x)    ((x)*DEG2RAD)

Function Documentation

int get_args ( int  argc,
char **  argv,
FILE **  ifp,
FILE **  ofp,
double *  angle 
)

Definition at line 67 of file rot.c.

References bu_exit(), bu_getopt(), bu_log(), bu_optarg, bu_opterr, bu_optind, BU_STR_EQUAL, invert, minus90, nxin, nyin, pixbytes, plus90, and reverse.

Referenced by ged_clone(), ged_fb2pix(), ged_pix2fb(), and icv_rot().

Here is the call graph for this function:

int icv_rot ( int  argv,
char **  argc 
)

Rotate an image. s [-rifb | -a angle] [-# bytes] [-s squaresize] [-w width] [-n height] [-o outputfile] inputfile [> outputfile]

Definition at line 285 of file rot.c.

References bp, bu_exit(), bu_free(), bu_fseek(), bu_log(), bu_malloc(), bu_setprogname(), buflines, firsty, get_args(), invert, lasty, minus90, nxin, nyin, obp, pixbytes, plus90, reverse, scanbytes, SEEK_SET, xout, yin, and yout.

Here is the call graph for this function:

Variable Documentation

ssize_t buflines

Definition at line 53 of file rot.c.

Referenced by icv_rot().

ssize_t scanbytes

Definition at line 53 of file rot.c.

Referenced by fb_read_fd(), fb_write_fp(), and icv_rot().

ssize_t firsty = -1

Definition at line 54 of file rot.c.

Referenced by icv_rot().

ssize_t lasty = -1

Definition at line 55 of file rot.c.

Referenced by icv_rot().

unsigned char* obp

Definition at line 57 of file rot.c.

Referenced by icv_rot().

ssize_t nxin = 512

Definition at line 59 of file rot.c.

Referenced by get_args(), and icv_rot().

ssize_t nyin = 512

Definition at line 60 of file rot.c.

Referenced by get_args(), and icv_rot().

ssize_t yin

Definition at line 61 of file rot.c.

Referenced by icv_rot().

ssize_t xout

Definition at line 61 of file rot.c.

Referenced by fb_read_fd(), and icv_rot().

ssize_t yout

Definition at line 61 of file rot.c.

Referenced by fb_read_fd(), and icv_rot().

int plus90

Definition at line 62 of file rot.c.

Referenced by get_args(), and icv_rot().

int minus90

Definition at line 62 of file rot.c.

Referenced by get_args(), and icv_rot().

int reverse

Definition at line 62 of file rot.c.

Referenced by get_args(), and icv_rot().

int invert

Definition at line 62 of file rot.c.

Referenced by get_args(), and icv_rot().

size_t pixbytes = 1

Definition at line 63 of file rot.c.

Referenced by get_args(), and icv_rot().