home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
625.lha
/
STScan_v2.0
/
localop.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-22
|
13KB
|
442 lines
/*localop.c local operations for stscan.c*/
#include <exec/exec.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <graphics/rastport.h>
#include <libraries/reqbase.h>
#include <req_pragmas.h>
#include <stdio.h>
#include <string.h>
#include <functions.h>
#include "stscan.h"
void lowpass()
{ UBYTE *picptr,*cpyptr;
ULONG x,y,cnt;
ULONG lin1ofs,lin2ofs;
UBYTE b,v,i;
char wtitel[20];
SetWindowTitles(win,"Moving",(UBYTE *)-1);
picptr=memptr+memneed;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memneed;cnt++)
*(--cpyptr)=*(--picptr);
picptr=memptr;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
lin1ofs=memwidth>>1;
lin2ofs=memwidth;
SetWindowTitles(win,"Processing 000%",(UBYTE *)-1);
for (y=1;y<memheight-1;y++)
{ b=15;
for (x=1;x<memwidth-1;x++)
{ if (x&1)
{ v=((*(cpyptr )&0x0f)+(*(cpyptr+ 1)>>4)+(*(cpyptr+ 1)&0x0f)
+(*(cpyptr+lin1ofs)&0x0f)+(*(cpyptr+lin1ofs+1)>>4)+(*(cpyptr+lin1ofs+1)&0x0f)
+(*(cpyptr+lin2ofs)&0x0f)+(*(cpyptr+lin2ofs+1)>>4)+(*(cpyptr+lin2ofs+1)&0x0f))/9;
*(picptr++)=(b<<4)|v;
cpyptr++;
}
else
{ b=((*(cpyptr )>>4)+(*(cpyptr )&0x0f)+(*(cpyptr+ 1)>>4)
+(*(cpyptr+lin1ofs)>>4)+(*(cpyptr+lin1ofs)&0x0f)+(*(cpyptr+lin1ofs+1)>>4)
+(*(cpyptr+lin2ofs)>>4)+(*(cpyptr+lin2ofs)&0x0f)+(*(cpyptr+lin2ofs+1)>>4))/9;
}
}
*(picptr++)=(b<<4)|15;
cpyptr+=1;
if (!(y%100))
{ sprintf(&wtitel,"Processing %03d %%",y*100/memheight);
SetWindowTitles(win,&wtitel[0],(UBYTE *)-1);
}
}
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
SetWindowTitles(win," ",(UBYTE *)-1);
}
void highpass()
{ UBYTE *picptr,*cpyptr;
ULONG x,y,cnt;
ULONG lin1ofs,lin2ofs;
BYTE b,v,i;
char wtitel[20];
SetWindowTitles(win,"Moving",(UBYTE *)-1);
picptr=memptr+memneed;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memneed;cnt++)
*(--cpyptr)=*(--picptr);
picptr=memptr;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
lin1ofs=memwidth>>1;
lin2ofs=memwidth;
SetWindowTitles(win,"Processing 000%",(UBYTE *)-1);
for (y=1;y<memheight-1;y++)
{ b=15;
for (x=1;x<memwidth-1;x++)
{ if (x&1)
{ v=(-(*(cpyptr )&0x0f) -(*(cpyptr+ 1)>>4)-(*(cpyptr+ 1)&0x0f)
-(*(cpyptr+lin1ofs)&0x0f)+8*(*(cpyptr+lin1ofs+1)>>4)-(*(cpyptr+lin1ofs+1)&0x0f)
-(*(cpyptr+lin2ofs)&0x0f) -(*(cpyptr+lin2ofs+1)>>4)-(*(cpyptr+lin2ofs+1)&0x0f));
if (v<0) v=0;
if (v>15) v=15;
*(picptr++)=(b<<4)|v;
cpyptr++;
}
else
{ b=(-(*(cpyptr )>>4) -(*(cpyptr )&0x0f)-(*(cpyptr+ 1)>>4)
-(*(cpyptr+lin1ofs)>>4)+8*(*(cpyptr+lin1ofs)&0x0f)-(*(cpyptr+lin1ofs+1)>>4)
-(*(cpyptr+lin2ofs)>>4) -(*(cpyptr+lin2ofs)&0x0f)-(*(cpyptr+lin2ofs+1)>>4));
if (b<0) b=0;
if (b>15) b=15;
}
}
*(picptr++)=(b<<4)|15;
cpyptr+=1;
if (!(y%100))
{ sprintf(&wtitel,"Processing %03d %%",y*100/memheight);
SetWindowTitles(win,&wtitel[0],(UBYTE *)-1);
}
}
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
SetWindowTitles(win," ",(UBYTE *)-1);
}
void blowpass()
{ UBYTE *picptr,*cpyptr;
ULONG x,y,cnt;
ULONG lin1ofs,lin2ofs,lin3ofs,lin4ofs;
UWORD b,v,i;
char wtitel[20];
SetWindowTitles(win,"Moving",(UBYTE *)-1);
picptr=memptr+memneed;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memneed;cnt++)
*(--cpyptr)=*(--picptr);
picptr=memptr;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memwidth;cnt++) *(picptr++)=255;
lin1ofs=memwidth>>1;
lin2ofs=2*lin1ofs;
lin3ofs=lin1ofs+lin2ofs;
lin4ofs=2*lin2ofs;
SetWindowTitles(win,"Processing 000%",(UBYTE *)-1);
for (y=2;y<memheight-2;y++)
{ *(picptr++)=255;
for (x=2;x<memwidth-2;x++)
{ if (x&1)
{ v= (*(cpyptr )&0x0f)
+(*(cpyptr+ 1)>>4)
+(*(cpyptr+ 1)&0x0f)
+(*(cpyptr+ 2)>>4)
+(*(cpyptr+ 2)&0x0f)
+ (*(cpyptr+lin1ofs )&0x0f)
+(*(cpyptr+lin1ofs+1)>>4)
+(*(cpyptr+lin1ofs+1)&0x0f)
+(*(cpyptr+lin1ofs+2)>>4)
+(*(cpyptr+lin1ofs+2)&0x0f)
+ (*(cpyptr+lin2ofs )&0x0f)
+(*(cpyptr+lin2ofs+1)>>4)
+(*(cpyptr+lin2ofs+1)&0x0f)
+(*(cpyptr+lin2ofs+2)>>4)
+(*(cpyptr+lin2ofs+2)&0x0f)
+ (*(cpyptr+lin3ofs )&0x0f)
+(*(cpyptr+lin3ofs+1)>>4)
+(*(cpyptr+lin3ofs+1)&0x0f)
+(*(cpyptr+lin3ofs+2)>>4)
+(*(cpyptr+lin3ofs+2)&0x0f)
+ (*(cpyptr+lin4ofs )&0x0f)
+(*(cpyptr+lin4ofs+1)>>4)
+(*(cpyptr+lin4ofs+1)&0x0f)
+(*(cpyptr+lin4ofs+2)>>4)
+(*(cpyptr+lin4ofs+2)&0x0f);
*(picptr++)=(((b/25)&0x0f)<<4)|((v/25)&0x0f);
cpyptr++;
}
else
{ b= (*(cpyptr )>>4)
+(*(cpyptr )&0x0f)
+(*(cpyptr+ 1)>>4)
+(*(cpyptr+ 1)&0x0f)
+(*(cpyptr+ 2)>>4)
+ (*(cpyptr+lin1ofs )>>4)
+(*(cpyptr+lin1ofs )&0x0f)
+(*(cpyptr+lin1ofs+1)>>4)
+(*(cpyptr+lin1ofs+1)&0x0f)
+(*(cpyptr+lin1ofs+2)>>4)
+ (*(cpyptr+lin2ofs )>>4)
+(*(cpyptr+lin2ofs )&0x0f)
+(*(cpyptr+lin2ofs+1)>>4)
+(*(cpyptr+lin2ofs+1)&0x0f)
+(*(cpyptr+lin2ofs+2)>>4)
+ (*(cpyptr+lin3ofs )>>4)
+(*(cpyptr+lin3ofs )&0x0f)
+(*(cpyptr+lin3ofs+1)>>4)
+(*(cpyptr+lin3ofs+1)&0x0f)
+(*(cpyptr+lin3ofs+2)>>4)
+ (*(cpyptr+lin4ofs )>>4)
+(*(cpyptr+lin4ofs )&0x0f)
+(*(cpyptr+lin4ofs+1)>>4)
+(*(cpyptr+lin4ofs+1)&0x0f)
+(*(cpyptr+lin4ofs+2)>>4);
}
}
*(picptr++)=255;
cpyptr+=2;
if (!(y%100))
{ sprintf(&wtitel,"Processing %03d %%",y*100/memheight);
SetWindowTitles(win,&wtitel[0],(UBYTE *)-1);
}
}
for (cnt=0;cnt<memwidth;cnt++) *(picptr++)=255;
SetWindowTitles(win," ",(UBYTE *)-1);
}
void relief()
{ UBYTE *picptr,*cpyptr;
ULONG x,y,cnt;
ULONG lin1ofs,lin2ofs;
BYTE b,v,i;
char wtitel[20];
SetWindowTitles(win,"Moving",(UBYTE *)-1);
picptr=memptr+memneed;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memneed;cnt++)
*(--cpyptr)=*(--picptr);
picptr=memptr;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
lin1ofs=memwidth>>1;
lin2ofs=memwidth;
SetWindowTitles(win,"Processing 000%",(UBYTE *)-1);
for (y=1;y<memheight-1;y++)
{ b=15;
for (x=1;x<memwidth-1;x++)
{ if (x&1)
{ v=( (*(cpyptr )&0x0f) +(*(cpyptr+ 1)>>4)
+(*(cpyptr+lin1ofs)&0x0f) -(*(cpyptr+lin1ofs+1)&0x0f)
-(*(cpyptr+lin2ofs+1)>>4) -(*(cpyptr+lin2ofs+1)&0x0f))+8;
if (v<0) v=0;
if (v>15) v=15;
*(picptr++)=(b<<4)|v;
cpyptr++;
}
else
{ b=( (*(cpyptr )>>4) +(*(cpyptr )&0x0f)
+(*(cpyptr+lin1ofs)>>4) -(*(cpyptr+lin1ofs+1)>>4)
-(*(cpyptr+lin2ofs)&0x0f) -(*(cpyptr+lin2ofs+1)>>4))+8;
if (b<0) b=0;
if (b>15) b=15;
}
}
*(picptr++)=(b<<4)|15;
cpyptr+=1;
if (!(y%100))
{ sprintf(&wtitel,"Processing %03d %%",y*100/memheight);
SetWindowTitles(win,&wtitel[0],(UBYTE *)-1);
}
}
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
SetWindowTitles(win," ",(UBYTE *)-1);
}
void minop()
{ UBYTE *picptr,*cpyptr;
ULONG x,y,cnt;
ULONG lin1ofs,lin2ofs;
UBYTE b,v,i,p[9];
char wtitel[20];
SetWindowTitles(win,"Moving",(UBYTE *)-1);
picptr=memptr+memneed;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memneed;cnt++)
*(--cpyptr)=*(--picptr);
picptr=memptr;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
lin1ofs=memwidth>>1;
lin2ofs=memwidth;
SetWindowTitles(win,"Processing 000%",(UBYTE *)-1);
for (y=1;y<memheight-1;y++)
{ b=15;
for (x=1;x<memwidth-1;x++)
{ if (x&1)
{ p[0]=(*(cpyptr )&0x0f);
p[1]=(*(cpyptr+ 1)>>4);
p[2]=(*(cpyptr+ 1)&0x0f);
p[3]=(*(cpyptr+lin1ofs )&0x0f);
p[4]=(*(cpyptr+lin1ofs+1)>>4);
p[5]=(*(cpyptr+lin1ofs+1)&0x0f);
p[6]=(*(cpyptr+lin2ofs )&0x0f);
p[7]=(*(cpyptr+lin2ofs+1)>>4);
p[8]=(*(cpyptr+lin2ofs+1)&0x0f);
v=15;
for (i=0;i<9;i++) if (p[i]<v) v=p[i];
*(picptr++)=(b<<4)|v;
cpyptr++;
}
else
{ p[0]=(*(cpyptr )>>4);
p[1]=(*(cpyptr )&0x0f);
p[2]=(*(cpyptr+ 1)>>4);
p[3]=(*(cpyptr+lin1ofs )>>4);
p[4]=(*(cpyptr+lin1ofs )&0x0f);
p[5]=(*(cpyptr+lin1ofs+1)>>4);
p[6]=(*(cpyptr+lin2ofs )>>4);
p[7]=(*(cpyptr+lin2ofs+1)&0x0f);
p[8]=(*(cpyptr+lin2ofs+1)>>4);
b=15;
for (i=0;i<9;i++) if (p[i]<b) b=p[i];
}
}
*(picptr++)=(b<<4)|15;
cpyptr+=1;
if (!(y%100))
{ sprintf(&wtitel,"Processing %03d %%",y*100/memheight);
SetWindowTitles(win,&wtitel[0],(UBYTE *)-1);
}
}
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
SetWindowTitles(win," ",(UBYTE *)-1);
}
void maxop()
{ UBYTE *picptr,*cpyptr;
ULONG x,y,cnt;
ULONG lin1ofs,lin2ofs;
UBYTE b,v,i,p[9];
char wtitel[20];
SetWindowTitles(win,"Moving",(UBYTE *)-1);
picptr=memptr+memneed;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memneed;cnt++)
*(--cpyptr)=*(--picptr);
picptr=memptr;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
lin1ofs=memwidth>>1;
lin2ofs=memwidth;
SetWindowTitles(win,"Processing 000%",(UBYTE *)-1);
for (y=1;y<memheight-1;y++)
{ b=15;
for (x=1;x<memwidth-1;x++)
{ if (x&1)
{ p[0]=(*(cpyptr )&0x0f);
p[1]=(*(cpyptr+ 1)>>4);
p[2]=(*(cpyptr+ 1)&0x0f);
p[3]=(*(cpyptr+lin1ofs )&0x0f);
p[4]=(*(cpyptr+lin1ofs+1)>>4);
p[5]=(*(cpyptr+lin1ofs+1)&0x0f);
p[6]=(*(cpyptr+lin2ofs )&0x0f);
p[7]=(*(cpyptr+lin2ofs+1)>>4);
p[8]=(*(cpyptr+lin2ofs+1)&0x0f);
v=0;
for (i=0;i<9;i++) if (p[i]>v) v=p[i];
*(picptr++)=(b<<4)|v;
cpyptr++;
}
else
{ p[0]=(*(cpyptr )>>4);
p[1]=(*(cpyptr )&0x0f);
p[2]=(*(cpyptr+ 1)>>4);
p[3]=(*(cpyptr+lin1ofs )>>4);
p[4]=(*(cpyptr+lin1ofs )&0x0f);
p[5]=(*(cpyptr+lin1ofs+1)>>4);
p[6]=(*(cpyptr+lin2ofs )>>4);
p[7]=(*(cpyptr+lin2ofs+1)&0x0f);
p[8]=(*(cpyptr+lin2ofs+1)>>4);
b=0;
for (i=0;i<9;i++) if (p[i]>b) b=p[i];
}
}
*(picptr++)=(b<<4)|15;
cpyptr+=1;
if (!(y%100))
{ sprintf(&wtitel,"Processing %03d %%",y*100/memheight);
SetWindowTitles(win,&wtitel[0],(UBYTE *)-1);
}
}
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
SetWindowTitles(win," ",(UBYTE *)-1);
}
static void sort(UBYTE *p,UBYTE n)
{ UBYTE f,i,j,t;
do {
f=0;
for (i=0;i<(n-1);i++)
if (*(p+i) > *(p+i+1))
{ t=*(p+i+1); *(p+i+1)=*(p+i); *(p+i)=t; f=1;}
} while (f);
}
void median()
{ UBYTE *picptr,*cpyptr;
ULONG x,y,cnt;
ULONG lin1ofs,lin2ofs;
UBYTE b,v,i,p[9];
char wtitel[20];
SetWindowTitles(win,"Moving",(UBYTE *)-1);
picptr=memptr+memneed;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<memneed;cnt++)
*(--cpyptr)=*(--picptr);
picptr=memptr;
cpyptr=picptr+(ULONG)(memwidth*2);
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
lin1ofs=memwidth>>1;
lin2ofs=memwidth;
SetWindowTitles(win,"Processing 000%",(UBYTE *)-1);
for (y=1;y<memheight-1;y++)
{ b=15;
for (x=1;x<memwidth-1;x++)
{ if (x&1)
{ p[0]=(*(cpyptr )&0x0f);
p[1]=(*(cpyptr+ 1)>>4);
p[2]=(*(cpyptr+ 1)&0x0f);
p[3]=(*(cpyptr+lin1ofs )&0x0f);
p[4]=(*(cpyptr+lin1ofs+1)>>4);
p[5]=(*(cpyptr+lin1ofs+1)&0x0f);
p[6]=(*(cpyptr+lin2ofs )&0x0f);
p[7]=(*(cpyptr+lin2ofs+1)>>4);
p[8]=(*(cpyptr+lin2ofs+1)&0x0f);
sort(p,9);
*(picptr++)=(b<<4)|p[4];
cpyptr++;
}
else
{ p[0]=(*(cpyptr )>>4);
p[1]=(*(cpyptr )&0x0f);
p[2]=(*(cpyptr+ 1)>>4);
p[3]=(*(cpyptr+lin1ofs )>>4);
p[4]=(*(cpyptr+lin1ofs )&0x0f);
p[5]=(*(cpyptr+lin1ofs+1)>>4);
p[6]=(*(cpyptr+lin2ofs )>>4);
p[7]=(*(cpyptr+lin2ofs )&0x0f);
p[8]=(*(cpyptr+lin2ofs+1)>>4);
sort(p,9);
b=p[4];
}
}
*(picptr++)=(b<<4)|15;
cpyptr+=1;
if (!(y%30))
{ sprintf(&wtitel,"Processing %03d %%",y*100/memheight);
SetWindowTitles(win,&wtitel[0],(UBYTE *)-1);
}
}
for (cnt=0;cnt<(memwidth>>1);cnt++) *(picptr++)=255;
SetWindowTitles(win," ",(UBYTE *)-1);
}