|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T w
Length: 2300 (0x8fc)
Types: TextFile
Names: »wrt.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/X/Xmandel/wrt.c«
#include <stdio.h>
#include <sys/file.h>
#include <math.h>
#include <rasterfile.h>
#define XSIZ 1152
#define YSIZ 900
#define TOTSIZ 1036800
#define LINE 80
#define MAXCHAR 256
extern double xin,yin,scale;
extern int nomin,nomax;
int head[] = {
RAS_MAGIC,
XSIZ, /* Width */
YSIZ, /* height */
8, /* depth */
TOTSIZ, /* length - set later */
RT_STANDARD, /* type 1 rasterfile */
RMT_EQUAL_RGB, /* RGB vectors */
768 /* Size of colormap = 3*256 */
};
writeman(func)
int (*func)();
{
char filename[LINE];
char instr[LINE];
unsigned char *buffer;
unsigned char colormap[768];
int rsiz,fd;
int nrx,nry;
int i,j;
unsigned char n;
double x,xstart,y,ystart;
double pscale,dx,dy;
fprintf(stderr,"Name of file: ");
fflush(stderr);
fgets(instr, LINE, stdin);
sscanf(instr,"%s",filename);
rsiz = igetd("resolution scale", 1);
if ((fd = open(filename,O_CREAT|O_WRONLY,0644))==-1){
fprintf(stderr,"Sorry, can't open file\n");
exit(-1);
}
if (fork()) exit(0);
write(fd, head, sizeof(head));
putcolor(colormap);
write(fd, colormap, 768);
buffer = (unsigned char *) malloc(TOTSIZ*sizeof(char));
nrx = (int) ceil(((double) XSIZ)/rsiz);
nry = (int) ceil(((double) YSIZ)/rsiz);
/* write(fd, &nrx, sizeof(int));
write(fd, &nry, sizeof(int));*/
pscale = nrx*scale;
dy = dx = 2/pscale;
xstart = xin - nrx/pscale;
ystart = yin - nry/pscale;
for (y=ystart, j=0;j<nry;j++,y += dy)
for (x = xstart,i=0;i<nrx;i++,x += dx){
n = abs((*func)(x,y))%MAXCHAR;
if (n==0) n=1;
else n = (2 + ((n - nomin)*(MAXCHAR-2)) /
(nomax-nomin)) % MAXCHAR;
writebuf(buffer, n, i, j, rsiz);
}
close(fd);
}
writebuf(buf, c, x, y, rsiz)
unsigned char *buf, c;
int x, y, rsiz;
{
int index,i,j,ind;
index = x*rsiz + y*rsiz*XSIZ;
for (i=0;i<rsiz;i++){
ind = index + i*XSIZ;
for(j = 0;j<rsiz;j++){
if (ind >= TOTSIZ) break;
buf[ind++] = c;
}
}
}
igetd(mesg,deflt)
char *mesg;
int deflt;
{
int i;
char s[LINE];
fprintf(stderr,"*Enter %s [%d]: ",mesg,deflt);
fflush(stderr);
if (!fgets(s,LINE,stdin)) exit(-1);
if(sscanf(s,"%d%>",&i)==EOF)
return(deflt);
else
return(i);
}
#include "colors.h"
putcolor(cm)
unsigned char *cm;
{
int i, j;
for (i=0;i<3;i++)
for (j=0;j<256;j++)
*cm++ = colors[3*j + i];
}