Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
fant.c
Go to the documentation of this file.
1 /*
2  * This software is copyrighted as noted below. It may be freely copied,
3  * modified, and redistributed, provided that the copyright notice is
4  * preserved on all copies.
5  *
6  * There is no warranty or other guarantee of fitness for this software,
7  * it is provided solely "as is". Bug reports or fixes may be sent
8  * to the author, who may or may not act on them as he desires.
9  *
10  * You may not include this software in a program or other software product
11  * without supplying the source, or without informing the end-user that the
12  * source is available for no extra charge.
13  *
14  * If you modify this software, you should include a notice giving the
15  * name of the person performing the modification, the date of modification,
16  * and the reason for such modification.
17  */
18 /*
19  * fant.c - Perform spacial transforms on images. (should be "remap")
20  *
21  * Author: John W. Peterson
22  * Computer Science Dept.
23  * University of Utah
24  * Date: Wed Jun 25 1986
25  * Copyright (c) 1986 John W. Peterson
26  *
27  * Last Modified by:
28  * James S. Painter
29  * Computer Science Dept.
30  * University of Utah
31  *
32  * Date: Fri Jun 15 1990
33  * Purpose: Add -b option; speed up inner loop through fixed point arithmetic
34  *
35  * Date: Fri Nov 23 1990
36  * Purpose: Add -S option; change coordinate system convention so that
37  * scale factors are more intuitive; Redo interp_row (sigh, again);
38  * added blur_factor to -b argument
39  *
40  * Spencer W. Thomas
41  * EECS Dept.
42  * University of Michigan
43  * Date: Feb 19, 1991
44  * Purpose: Add -c option: scale image so that it fits in -S
45  * rectangle, but keep its aspect ratio constant, and center
46  * the result if it doesn't exactly fit the rectangle.
47  *
48  * $Id: fant.c,v 3.0.1.4 1992/04/30 14:09:57 spencer Exp $
49  */
50 
51 /*
52  * This program performs spatial transforms on images. For full
53  * details, consult the paper:
54  * Fant, Karl M. "A Nonaliasing, Real-Time, Spatial Transform
55  * Technique", IEEE CG&A, January 1986, p. 71
56  *
57  * Editorial note: This is not a particularly elegant example of toolkit
58  * programming.
59  */
60 
61 #include <stdio.h>
62 #include <math.h>
63 #include "rle.h"
64 
65 #define MAXCHAN 256
66 
67 #ifndef PI
68 #define PI 3.14159265358979323846
69 #endif
70 
71 
72 #define H_PASS 0
73 #define V_PASS 1
74 
75 /* Conversion macros */
76 
77 #define FRAC(x) ((x) - ((int) floor(x)))
78 #define ROUND(x) ((int)((x) + 0.5))
79 #define DEG(x) ((x) * PI / 180.0)
80 #define EPSILON .0001
81 
82 #define MIN(x,y) ((x) < (y) ? (x) : (y))
83 #define MAX(x,y) ((x) > (y) ? (x) : (y))
84 
85 
86 
87 typedef struct point
88 {
89  double x,y;
90 } point;
91 
92 /*
93  * Each channel is stored in its own raster (an array_lines * array_width
94  * array of pixels). This allows each channel to be transformed separately.
95  * A single copy is used and updated in place.
96  */
98 rle_pixel *bufin; /* A single channel scanline */
99 
100 int const_ind; /* Constant index */
101 int cur_chan; /* Which channel we're munging */
102 int pass; /* Which pass we're on (h or v) */
103 rle_hdr in_hdr, out_hdr;
104 int nchan;
105 int array_width; /* Width of getrow line (0..xmax) */
107 int verboseflag; /* Be chatty (Fant can be slow) */
108 int originflag; /* Center picture on given orig instead of center */
110 int vpassonlyflag; /* If true, we only need the vertical pass */
111 
112 
113 /* External and Forward declarations */
114 extern void *mallocNd();
117 
118 
119 void
121 int argc;
122 char *argv[];
123 {
124  char *infilename = NULL,
125  *out_fname = NULL;
126  int oflag = 0;
127  int rle_cnt;
128  int scaleflag = 0,
129  sizeflag = 0,
130  centerflag = 0,
131  angleflag = 0,
132  translateflag = 0,
133  blurflag = 0;
134  double xscale = 1.0,
135  yscale = 1.0,
136  xsize,
137  ysize,
138  blur = 1.0,
139  angle = 0.0,
140  xtrans = 0.0,
141  ytrans = 0.0;
142  FILE *outfile = stdout;
143  int rle_err;
144  int i, i1, i2;
145  point p[5]; /* "5" so we can use 1-4 indices Fant does. */
146  int dims[3];
147 
148 
149  X_origin = 0;
150  Y_origin = 0;
151  verboseflag = 0;
152  originflag = 0;
153  vpassonlyflag = 0;
154 
155  if (scanargs( argc, argv,
156 "% s%-xscale!Fyscale!F S%-xsize!Fysize!F c%- a%-angle!F b%-blur!F v%- \
157 p%-xorg!dyorg!d t%-xoff!Fyoff!F \to%-outfile!s infile%s",
158  &scaleflag, &xscale, &yscale,
159  &sizeflag, &xsize, &ysize, &centerflag,
160  &angleflag, &angle,
161  &blurflag, &blur,
163  &translateflag, &xtrans, &ytrans,
164  &oflag, &out_fname, &infilename ) == 0)
165  exit(-1);
166 
167  in_hdr = *rle_hdr_init( NULL );
168  out_hdr = *rle_hdr_init( NULL );
169 
170  in_hdr.rle_file = rle_open_f(cmd_name( argv ), infilename, "r");
171  rle_names( &in_hdr, cmd_name( argv ), infilename, 0 );
172  rle_names( &out_hdr, in_hdr.cmd, out_fname, 0 );
173 
174  if (fabs(angle) > 45.0)
175  fprintf(stderr,
176  "fant: Warning: angle larger than 45 degrees, image will blur.\n");
177 
178  if (sizeflag && (angleflag || scaleflag || originflag || translateflag))
179  {
180  fprintf( stderr,
181  "%s: size option (-S) is incompatible with the angle (-a), scale (-s),\n\
182  \ttranslate (-t) and origin (-p) options\n",
183  cmd_name( argv ) );
184  exit(-1);
185  }
186  if ( !sizeflag && centerflag )
187  fprintf( stderr,
188  "%s: center option (-c) ignored without size option (-S)\n",
189  cmd_name( argv ) );
190 
191  if (blur < 0)
192  {
193  fprintf( stderr, "fant: blur factor must be positive\n" );
194  exit(-1);
195  }
196 
197  if ((scaleflag && xscale == 1.0) && (angle == 0.0))
198  {
199  vpassonlyflag = 1;
200  if (verboseflag)
201  fprintf(stderr, "fant: Only performing vertical pass\n");
202  }
203 
204  for ( rle_cnt = 0;
205  (rle_err = rle_get_setup( &in_hdr )) == RLE_SUCCESS;
206  rle_cnt++ )
207  {
209 
210  (void)rle_hdr_cp( &in_hdr, &out_hdr );
211  if ( rle_cnt == 0 )
212  outfile = rle_open_f( cmd_name( argv ), out_fname, "w" );
213  out_hdr.rle_file = outfile;
214 
216 
217  /*
218  * To define the output rectangle, we start with a set of points
219  * defined by the original image, and then rotate and scale them
220  * as desired. Note that we use a continuous coordinate system:
221  * min to max+1 with pixel centers at the midpoints of each unit
222  * square.
223  *
224  * Mapping between coordinate systems:
225  * if c = continuous coord and d = discrete coord, then
226  * c = d+.5
227  * d = floor(c)
228  */
229  p[1].x = in_hdr.xmin; p[1].y = in_hdr.ymin;
230  p[2].x = in_hdr.xmax+1; p[2].y = in_hdr.ymin;
231  p[3].x = in_hdr.xmax+1; p[3].y = in_hdr.ymax+1;
232  p[4].x = in_hdr.xmin; p[4].y = in_hdr.ymax+1;
233 
234  if (sizeflag)
235  {
236  /* Compute the scale factors from the desired destination size*/
237  xscale = xsize / (p[2].x - p[1].x);
238  yscale = ysize / (p[3].y - p[2].y);
239  X_origin = p[1].x;
240  Y_origin = p[1].y;
241  /* If centering, adjust scale factors and origin. */
242  if ( centerflag )
243  {
244  if ( xscale < yscale )
245  {
246  yscale = xscale;
247  xtrans = 0;
248  ytrans = (ysize - (p[3].y - p[2].y) * yscale) / 2;
249  }
250  else
251  {
252  xscale = yscale;
253  xtrans = (xsize - (p[2].x - p[1].x) * xscale) / 2;
254  ytrans = 0;
255  }
256  }
257  originflag = 1;
258  }
259  xform_points(p, xscale, yscale, angle, xtrans, ytrans );
260 
261 
262 
263  /* Map the continous coordinates back to discrete coordinates to
264  * determine the output image size. We only output a pixel if it's
265  * a least partially covered. Partial, for us, means at least
266  * EPSILON coverage. This is a little arbitrary but ensures that
267  * extra pixels aren't included on the ends.
268  */
269 
270 
271  i1 = (int) (p[1].x + EPSILON);
272  i2 = (int) (p[4].x + EPSILON);
273  out_hdr.xmin = MAX(0,MIN(i1,i2));
274 
275  i1 = (int) (p[1].y + EPSILON);
276  i2 = (int) (p[2].y + EPSILON);
277  out_hdr.ymin = MAX(0,MIN(i1,i2));
278 
279  i1 = (int) (p[2].x - EPSILON);
280  i2 = (int) (p[3].x - EPSILON);
281  out_hdr.xmax = MAX(i1,i2);
282 
283  i1 = (int) (p[3].y - EPSILON);
284  i2 = (int) (p[4].y - EPSILON);
285  out_hdr.ymax = MAX(i1,i2);
286 
287 
288  /*
289  * Need to grab the largest dimensions so the buffers will hold the
290  * picture. The arrays for storing the pictures extend from 0
291  * to xmax in width and from ymin to ymax in height.
292  */
297 
298  /*
299  * Since the array begins at ymin, the four output corner points must be
300  * translated to this coordinate system.
301  */
302  for (i = 1; i <= 4; i++)
303  p[i].y -= MIN(out_hdr.ymin,in_hdr.ymin);
304 
305  /* Oink. */
306 
307  dims[0] = nchan;
308  dims[1] = array_lines;
309  dims[2] = array_width;
310  rast = (rle_pixel ***) mallocNd(3,dims,sizeof(rle_pixel));
311  bufin = (rle_pixel *)
312  malloc(MAX(array_lines,array_width)*sizeof(rle_pixel));
313  RLE_CHECK_ALLOC( cmd_name( argv ), rast && bufin, "raster" );
314 
316 
317  /* Transform each channel */
318  cur_chan = 0;
319  for (cur_chan = 0; cur_chan < nchan; cur_chan++)
320  xform_image(p,blur);
321 
323 
325  free(rast);
326  free(bufin);
327  }
328 
329  if ( rle_cnt == 0 || (rle_err != RLE_EOF && rle_err != RLE_EMPTY) )
330  rle_get_error( rle_err, cmd_name( argv ), infilename );
331  exit( 0 );
332 }
333 
334 /*
335  * This transforms one channel (defined by cur_chan) of the image.
336  * The result image is based on the points p, using linear
337  * interpolation per scanline.
338  */
339 void
341 point *p;
342 double blur;
343 {
344  double real_outpos, sizefac, delta;
345  int i1, i2, ystart, yend;
346  int xinlen = in_hdr.xmax - in_hdr.xmin + 1;
347  int yinlen = in_hdr.ymax - in_hdr.ymin + 1;
348 
349  if (verboseflag)
350  fprintf(stderr, "transforming channel %d...\n",
352 
353  /* Vertical pass */
354  pass = V_PASS;
355 /* clear_raster( rast ); */
356 
357  real_outpos = p[1].y;
358 
359  sizefac = (p[4].y-p[1].y) / (yinlen);
360  delta = (p[2].y - p[1].y) / (xinlen);
361 
362  for ( const_ind = in_hdr.xmin;
364  {
365  interp_row( sizefac, blur, 0, real_outpos,
367  array_lines-1 );
368  real_outpos += delta;
369  }
370 
371  if (! vpassonlyflag )
372  {
373  /* Horizontal pass */
374  pass = H_PASS;
375 
376  real_outpos = ( ((p[2].y - p[4].y) * (p[1].x - p[4].x))
377  / (p[1].y - p[4].y) ) + p[4].x;
378  sizefac = (p[2].x - real_outpos) / (xinlen);
379  delta = (p[4].x - real_outpos)
380  / ((double) ((int) p[4].y) - ((int) p[2].y));
381 
382  /* If we're moving backwards, start at p1 (needs more thought...) */
383  if (delta < 0)
384  real_outpos = p[1].x;
385 
386  i1 = (int) (p[1].y + EPSILON);
387  i2 = (int) (p[2].y + EPSILON);
388  ystart = MIN(i1,i2);
389 
390  i1 = (int) (p[3].y - EPSILON);
391  i2 = (int) (p[4].y - EPSILON);
392  yend = MAX(i1,i2);
393 
394  if (ystart < 0) /* Ensure start isn't negative */
395  {
396  real_outpos += delta * abs(ystart);
397  ystart = 0;
398  }
399 
400  for ( const_ind = ystart; const_ind <= yend; const_ind++ )
401  {
402  interp_row( sizefac, blur, in_hdr.xmin, real_outpos,
404  out_hdr.xmax );
405  real_outpos += delta;
406  }
407  }
408 }
409 
410 /*
411  * Transform the points p according to xscale, yscale and angle.
412  * Rotation is done first, this allows the separate scaling factors to
413  * be used to adjust aspect ratios. Note the image quality of the
414  * resulting transform degrades sharply if the angle is > 45 degrees.
415  */
416 void
418 point *p;
419 double xscale, yscale, angle, xtrans, ytrans;
420 {
421  double s, c, xoff, yoff;
422  double tmp;
423  int i;
424 
425  /* Sleazy - should build real matrix */
426 
427  c = cos(DEG(angle));
428  s = sin(DEG(angle));
429  if (!originflag)
430  {
431  xoff = ((double) (in_hdr.xmax - in_hdr.xmin + 1) / 2.0
432  + in_hdr.xmin);
433  yoff = ((double) (in_hdr.ymax - in_hdr.ymin + 1) / 2.0
434  + in_hdr.ymin);
435  }
436  else
437  {
438  xoff = X_origin;
439  yoff = Y_origin;
440  }
441  if (verboseflag)
442  fprintf(stderr, "Output rectangle:\n");
443 
444  for ( i = 1; i <= 4; i++ )
445  {
446  p[i].x -= xoff; /* translate to origin */
447  p[i].y -= yoff;
448 
449  tmp = p[i].x * c + p[i].y * s; /* Rotate... */
450  p[i].y = -p[i].x * s + p[i].y * c;
451  p[i].x = tmp;
452 
453  p[i].x *= xscale; /* Scale */
454  p[i].y *= yscale;
455 
456  p[i].x += ( xoff + xtrans ); /* translate back from origin */
457  p[i].y += ( yoff + ytrans );
458 
459  if (verboseflag)
460  fprintf(stderr, " %4.1f\t%4.1f\n", p[i].x, p[i].y);
461  }
462 }
463 
464 
465 
466 
467 /* Constants used for storing floats as scaled integers */
468 #define SHIFT 16
469 #define SCALE (1 << SHIFT)
470 
471 void
473 double sizefac; /* scale factor (maps input to output) */
474 double blur; /* blur factor 1.0 normal; <1 jaggy; > 1 blury */
475 int inmin; /* minimum index in input image */
476 double real_outpos; /* output coordinate of input 0 */
477 int inmax, outmax; /* upper bounds on image indices */
478 {
479  double pos, /* input coordinate of first output point */
480  delta, /* delta (in input coords) between output points */
481  radius; /* filter radius (in input coords) */
482  int xmin, xmax, /* index bounds in output array */
483  stride, /* stride between output array positions */
484  inlen; /* length of input buffer; */
485  register rle_pixel *pin, *pout, *pend, *p;
486 
487 
488  delta = 1/sizefac;
489 
490  radius = (sizefac > 1.0) ? 1.0 : delta; /* filter radius */
491  radius *= blur;
492  /* clamp the filter radius on the bottom end to make sure we get complete
493  coverage. */
494  if (radius < 0.5+EPSILON) radius = 0.5+EPSILON;
495 
496 
497  /*
498  * Find the bounds in the output array
499  */
500  /* min in output coords */
501  xmin = (int) floor((-radius)*sizefac + real_outpos);
502  if (xmin < 0) xmin = 0;
503  if (xmin > outmax) xmin = outmax;
504  xmax = floor(inmax - inmin + 1.0 + radius); /* max in input coordinates */
505  xmax = floor((xmax + 0.5)*sizefac + real_outpos); /* -> output coords */
506  if (xmax < 0) xmax = 0;
507  if (xmax > outmax) xmax = outmax;
508 
509  inlen = inmax - inmin + 1;
510  if (pass == V_PASS)
511  {
512  pin = rast[cur_chan][inmin]+const_ind;
513  pout = rast[cur_chan][0]+const_ind;
514  stride = array_width;
515  }
516  else
517  {
518  pin = rast[cur_chan][const_ind] + inmin;
519  pout = rast[cur_chan][const_ind] + 0;
520  stride = 1;
521  }
522 
523 
524  /*
525  * Copy the input into a row buffer. This saves us some memory so
526  * we don't need a separate output array for the whole image.
527  */
528  p = bufin;
529  pend = bufin + inlen;
530  while (p < pend)
531  {
532  *p++ = *pin;
533  pin += stride;
534  }
535  pin = bufin;
536 
537  /* zero out the part of the output array we aren't going to touch */
538  p = pout;
539  pend = p + stride*xmin;
540  while (p < pend)
541  { *p = 0; p += stride; }
542  p = pout + stride*(xmax+1);
543  pend = pout + stride*(outmax+1);
544  while (p < pend)
545  { *p = 0; p += stride; }
546  pout += stride*xmin;
547 
548  /* input coordinate of first output pixel center */
549  pos = (xmin + 0.5 - real_outpos)*delta;
550 
551  if (radius != 1.0)
552  general_interp_row(pin,inlen,pout,stride,xmin,xmax,pos,radius,delta);
553  else
554  fast_interp_row(pin,inlen,pout,stride,xmin,xmax, pos,delta);
555 }
556 
557 
558 /*
559  * Do the actual work of interp row. This version handles the general
560  * case of any filter radius.
561  */
563 register rle_pixel *pin; /* pointer to input buffer */
564 int inlen; /* length of input */
565 register rle_pixel *pout; /* pointer to array buffer */
566 int stride; /* stride between output values */
567 int xmin, xmax; /* range of output values */
568 double pos; /* input coord position of first output pixel */
569 double radius; /* triangle filter radius */
570 double delta; /* input coord delta between output pixels */
571 {
572  register long pxl, fpos, weight, sum, accum;
573  register int i, i0, i1, x;
574  long rpos, rradius, rdelta ;
575 
576 
577  /* This is the general case. We walk through all the output points.
578  * for each output point we map back into the input coordinate system
579  * to figure out which pixels affect it. We sum over all input pixels
580  * that overlap the filter support. A triangle filter is hardwired at
581  * present for speed.
582  */
583 
584  rpos = (long) (pos*SCALE + 0.5); /* fixed point forms */
585  rradius = (long) (radius*SCALE + 0.5);
586  rdelta = (long) (delta*SCALE + 0.5);
587 
588 
589  /* For each output pixel */
590  for (x=xmin; x<=xmax; x++)
591  {
592  /* find bounds in input array */
593 
594  i0 = (rpos - rradius + SCALE/2) >>SHIFT; /* floor(pos -radius +0.5); */
595  i1 = (rpos + rradius - SCALE/2) >>SHIFT; /* floor(pos +radius -0.5); */
596 
597  /* sum over each input pixel which effects this output pixel
598  * weights are taken from a triangle filter of width radius.
599  */
600  sum = accum = 0;
601  for(i=i0; i<=i1; i++)
602  {
603  /* lookup input pixel (zero's at boundaries) */
604  pxl = (i < 0 || i >= inlen) ? 0 : pin[i];
605 
606  /* map to filter coordinate system */
607  fpos = (i<<SHIFT) + SCALE/2 - rpos; /* fabs(i+0.5-pos); */
608  if (fpos < 0) fpos = -fpos;
609 
610  weight = rradius - fpos;
611  accum += pxl * weight;
612  sum += weight;
613  }
614  if (sum > 0)
615  *pout = accum/sum;
616 
617  /* advance to next input pixel (in src coordinates) */
618  rpos += rdelta; /* pos += delta */
619  pout += stride;
620  }
621 }
622 
623 
624 /*
625  * This is a special case of general_interp_row for use when the filter
626  * radius is exactly 1, a common case. It amounts to linear interpolation
627  * between the input pixels.
628  */
630 register rle_pixel *pin; /* pointer to input buffer */
631 int inlen; /* length of input */
632 register rle_pixel *pout; /* pointer to output buffer */
633 int stride; /* stride between array values */
634 int xmin, xmax; /* range of output values */
635 double pos; /* input coord of first output pixel center */
636 double delta; /* input coord delta between output pixels */
637 {
638  register long pv, nv, inseg;
639  register long rdelta;
640  register rle_pixel *pend;
641  long rpos;
642  int i;
643 
644  rpos = (long) (pos*SCALE + 0.5); /* fixed point forms */
645  rdelta = (long) (delta*SCALE + 0.5);
646 
647  /* find starting point in input array */
648  rpos -= SCALE/2;
649  i = (rpos >> SHIFT);
650  inseg = (rpos - (i << SHIFT));
651  if (inseg < 0) { i++; inseg += SCALE; }
652  if (i > 0) pin+= i;
653 
654  /* Lookup initial pixel values */
655  if (i < 0 || i >= inlen) pv = 0; else { pv = *pin; pin++; }
656  i++;
657  if (i < 0 || i >= inlen) nv = 0; else { nv = *pin; pin++; }
658 
659  /* Loop over output pixels */
660  pend = pout + (xmax-xmin)*stride + 1;
661  while (pout < pend)
662  {
663  /* Simple linear interpolation */
664  *pout = (pv*(SCALE-inseg) + nv*inseg + SCALE/2) >> SHIFT;
665 
666  /* advance to next input pixel (in src coordinates) */
667  inseg += rdelta;
668  if (inseg > SCALE)
669  {
670  pv = nv;
671  i++;
672  if (i < 0 || i >= inlen)
673  nv = 0;
674  else
675  { nv = *pin; pin++; }
676  inseg -= SCALE;
677  }
678  pout += stride;
679  }
680 }
681 
682 
683 /*
684  * Read all channels of the picture in, placing each channel directly
685  * into a separate array.
686  */
687 void
689 rle_pixel ***ras_ptrs;
690 {
691  int i, chan;
692  rle_pixel *ptrs[MAXCHAN];
693  rle_pixel *rows[MAXCHAN]; /* Pointers for getrow/putrow */
694 
695  for ( chan = 0; chan < nchan; chan++ )
696  ptrs[chan] = ras_ptrs[chan][0];
697 
698  for (i = in_hdr.ymin; i <= in_hdr.ymax; i++)
699  {
700  for ( chan = 0; chan < nchan; chan++ )
701  rows[chan] = ptrs[chan];
702  rle_getrow( &in_hdr, &(rows[in_hdr.alpha]) );
703 
704 
705  /* Bump pointers */
706  for ( chan = 0; chan < nchan; chan++ )
707  ptrs[chan] += array_width;
708  }
709 }
710 
711 /* Write out the rasters */
712 void
714 rle_pixel ***ras_ptrs;
715 {
716  int i, chan;
717  rle_pixel *ptrs[MAXCHAN];
718  rle_pixel *rows[MAXCHAN]; /* Pointers for getrow/putrow */
719 
721 
722  /*
723  * If the output image is smaller than the input, we must offset
724  * into the pixel array by the difference between the two.
725  */
727  for ( chan = 0; chan < nchan; chan++ )
728  ptrs[chan] = ras_ptrs[chan][(out_hdr.ymin - in_hdr.ymin)];
729  else
730  for ( chan = 0; chan < nchan; chan++ )
731  ptrs[chan] = ras_ptrs[chan][0];
732 
733  for (i = out_hdr.ymin; i <= out_hdr.ymax; i++)
734  {
735  for ( chan = 0; chan < nchan; chan++ )
736  rows[chan] = &((ptrs[chan])[out_hdr.xmin]);
738 
739  /* Bump pointers */
740  for ( chan = 0; chan < nchan; chan++ )
741  ptrs[chan] += array_width;
742  }
743 }
744 
745 /* Clear the raster's cur_chan channel */
746 void
748 rle_pixel ***ras_ptr;
749 {
750  bzero( &(ras_ptr[cur_chan][0][0]), array_width * array_lines );
751 }
752 
753 #ifdef DEBUG
754 /*
755  * Dump out a raster (used for debugging).
756  */
757 void
758 dumpraster(ras_ptrs)
759 rle_pixel ***ras_ptrs;
760 {
761  int x, y, xmin, ymin, xmax, ymax, chan;
762 
763  ymin = MIN(out_hdr.ymin,in_hdr.ymin);
764  ymax = MAX(out_hdr.ymax,in_hdr.ymax) - ymin;
765  xmin = MIN(out_hdr.xmin,in_hdr.xmin);
766  xmax = MAX(out_hdr.xmax,in_hdr.xmax);
767 
768  for ( chan = 0; chan < nchan; chan++ )
769  for (y = ymax; y >=0 ; y--)
770  {
771  for (x=xmin; x<=xmax; x++)
772  {
773  fprintf(stderr, "%2x ", ras_ptrs[chan][y][x]);
774  }
775  fprintf(stderr,"\n");
776  }
777 
778 }
779 #endif
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
Definition: rle_open_f.c:216
#define MIN(x, y)
Definition: rletopaint.c:53
int xmin
Definition: rle.h:100
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
Definition: rle_hdr.c:119
int pass
Definition: fant.c:102
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
Definition: rle_hdr.c:48
void xform_points(point *p, double xscale, double yscale, double angle, double xtrans, double ytrans)
Definition: fant.c:417
#define RLE_EMPTY
Definition: rle.h:73
char * cmd_name(char **argv)
Definition: cmd_name.c:31
#define H_PASS
Definition: fant.c:72
void main(int argc, char **argv)
Definition: aliastorle.c:121
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
#define DEG(x)
Definition: fant.c:79
int array_lines
Definition: fant.c:106
int rle_getrow(rle_hdr *the_hdr, scanline)
Definition: rle_getrow.c:333
rle_pixel * bufin
Definition: fant.c:98
#define RLE_SUCCESS
Definition: rle.h:70
int vpassonlyflag
Definition: fant.c:110
#define V_PASS
Definition: fant.c:73
int Y_origin
Definition: fant.c:109
int ymin
Definition: rle.h:100
int rle_get_error(int code, const char *pgmname, const char *fname)
Definition: rle_error.c:76
int X_origin
Definition: fant.c:109
#define MAXCHAN
Definition: fant.c:65
void clear_raster(rle_pixel ***ras_ptr)
Definition: fant.c:747
int verboseflag
Definition: fant.c:107
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
int cur_chan
Definition: fant.c:101
const char * cmd
Definition: rle.h:133
void rle_puteof(rle_hdr *the_hdr)
Definition: rle_putrow.c:474
#define EPSILON
Definition: fant.c:80
void putraster(rle_pixel ***ras_ptrs)
Definition: fant.c:713
void rle_putrow(rows, int rowlen, rle_hdr *the_hdr)
Definition: rle_putrow.c:96
int xmax
Definition: rle.h:100
double y
Definition: fant.c:89
rle_hdr out_hdr
Definition: unslice.c:34
void general_interp_row(rle_pixel *pin, int inlen, rle_pixel *pout, int stride, int xmin, int xmax, double pos, double radius, double delta)
Definition: fant.c:562
#define RLE_EOF
Definition: rle.h:74
void rle_addhist(argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
Definition: rle_addhist.c:54
rle_pixel *** rast
Definition: fant.c:97
#define SHIFT
Definition: fant.c:468
#define MAX(i, j)
Definition: get4d.c:23
double x
Definition: fant.c:89
void xform_image(point *p, double blur)
Definition: fant.c:340
Definition: fant.c:87
int ymax
Definition: rle.h:100
unsigned char rle_pixel
Definition: rle.h:56
char * mallocNd(unsigned int nDim, Dims, unsigned int sizeofelt)
Definition: mallocNd.c:125
void rle_put_setup(rle_hdr *the_hdr)
Definition: rle_putrow.c:453
int array_width
Definition: fant.c:105
void interp_row(double sizefac, double blur, int inmin, double real_outpos, int inmax, int outmax)
Definition: fant.c:472
int alpha
Definition: rle.h:100
int outlinewidth
Definition: fant.c:106
#define PI
Definition: fant.c:68
int nchan
Definition: fant.c:104
rle_hdr in_hdr
Definition: unslice.c:34
#define SCALE
Definition: fant.c:469
void fast_interp_row(rle_pixel *pin, int inlen, rle_pixel *pout, int stride, int xmin, int xmax, double pos, double delta)
Definition: fant.c:629
void getraster(rle_pixel ***ras_ptrs)
Definition: fant.c:688
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267
FILE * rle_file
Definition: rle.h:114
int const_ind
Definition: fant.c:100
int ncolors
Definition: rle.h:100
int originflag
Definition: fant.c:108
#define RLE_CHECK_ALLOC(pgm, ptr, name)
Definition: rle.h:86