Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
wedge.c
Go to the documentation of this file.
1 /*
2  * wedge.c - Step wedge for the QCR-Z
3  *
4  * Author: John W. Peterson
5  * Computer Science Dept.
6  * University of Utah
7  * Date: Thu Jan 14 1988
8  * Copyright (c) 1988, University of Utah
9  */
10 
11 #include <stdio.h>
12 #include "rle.h"
13 #include "qcr.h"
14 
15 #define IMG_WIDTH 2048
16 #define IMG_HEIGHT 1536
17 
18 /*
19  * The "+1" is so that we get the full dynamic range, 0..255. If we want
20  * 16 levels, this requires 17 steps to include the zero and full intensity.
21  */
22 #define STEPS (16+1)
23 
25 
26 static char * color_names[3] = { "red", "green", "blue" };
27 
29 {
30  register rle_pixel * rptr;
31  register int i,j,color, val;
32 
33  raster = (rle_pixel *) malloc( (STEPS * 2 + 2) * IMG_HEIGHT /*/4*/ );
34  rptr = raster;
35 
36  init_qcr( 1 );
37 
38  for (color = 0; color < 3; color++)
39  for (j = 0; j < IMG_HEIGHT/4; j++)
40  {
41  for (i = 0; i < STEPS; i++)
42  {
43  *rptr = IMG_WIDTH / STEPS;
44  val = i * (256 / (STEPS-1));
45  if (val >= 256)
46  {
47  val = 255;
48  /* Add round-off to fill out scanline */
49  *rptr += IMG_WIDTH - (STEPS * (IMG_WIDTH / STEPS));
50  }
51  rptr++;
52  *rptr++ = val;
53  }
54  }
55 
56  /* Do first three color bars. */
57  for (color = 0; color < 3; color++)
58  {
59  set_up_qcr( IMG_WIDTH, IMG_HEIGHT, IMG_HEIGHT/4,
60  color * (IMG_HEIGHT/4) );
61 
62  fprintf(stderr, "Sending color %s...\n", color_names[color] );
63  write_qcr_cmd( RED_RLE + color );
64 
65  if (write_data( raster, (STEPS * 2) * (IMG_HEIGHT / 4) ) <= 0)
66  perror("wedge: error sending data");
67  qcr_wait_srq();
68  fprintf(stderr, "...sent\n\n");
69  }
70 
71  color = 3;
72  set_up_qcr( IMG_WIDTH, IMG_HEIGHT, IMG_HEIGHT/4,
73  color * (IMG_HEIGHT/4) );
74 
75  fprintf(stderr, "Sending three passes (for gray)...\n");
76  write_qcr_cmd( THREE_PASS_RLE );
77 
78  if (write_data( raster, ((STEPS * 2) * (IMG_HEIGHT / 4)) * 3 ) <= 0)
79  perror("wedge: error sending data");
80  qcr_wait_srq();
81  fprintf(stderr, "...sent\n\n");
82 }
#define IMG_HEIGHT
Definition: wedge.c:16
#define THREE_PASS_RLE
Definition: qcr.h:32
static char * color_names[3]
Definition: wedge.c:26
void main(int argc, char **argv)
Definition: aliastorle.c:121
#define RED_RLE
Definition: qcr.h:43
#define IMG_WIDTH
Definition: wedge.c:15
#define STEPS
Definition: wedge.c:22
unsigned char rle_pixel
Definition: rle.h:56
rle_pixel * raster
Definition: wedge.c:24