' 'Colour Transformations 'Richard Wheeldon 1996 ' ' ' Does simple convolve operations. ' Load an image file then alter the ' map with the left mouse button or ' use the menus. ' Global DFS DFS=6 Dim DEF(DFS,15) Dim DEFNAME$(DFS) Dim CL(15) Global CL(),DEF(),DEFNAME$() 'Load Iff "dh0:clipart/kingtut.pp",0 Load Iff Fsel$("**","KingTut","Please load an IFF image file"),0 Screen Open 1,320,64,2,Lowres Curs Off : Flash Off : Paper 0 : Cls Palette $0,$FFF _SETDEFAULTS _SETMENUS LINE_MAKE[True] CURVE_SHOW Do SM=Mouse Screen Trap Screen SM XM=X Screen(X Mouse) YM=Y Screen(Y Mouse) MK=Mouse Key I$=Inkey$ If I$=" " Load Iff "dh0:clipart/kingtut.pp",0 Screen To Front 1 Else If I$=Chr$(27) Edit Else If MK=1 If SM=1 and XM>=0 and XM<=63 If CL(XM/4)<>15-YM/4 CL(XM/4)=15-YM/4 CURVE_SHOW End If End If End If Loop ' Procedure CURVE_SHOW Screen 1 Ink 0 : Bar 0,0 To 63,63 Ink 1 : Plot 0,4*(15-CL(0)) For C=1 To 15 Draw , To C*4,4*(15-CL(C)) Next End Proc Procedure LINE_MAKE[NEG] For C=0 To 15 If NEG CL(C)=15-C Else CL(C)=C End If Next End Proc Procedure TRANSFORM_COLOR For C=0 To Screen Colour-1 R=Colour(C)/256 G=(Colour(C)/16) and 15 B=Colour(C) and 15 R=CL(R) G=CL(G) B=CL(B) Colour C,R*256+G*16+B Next End Proc Procedure _SETMENUS Screen 1 Menu$(1)=" Process " Menu$(1,1)=" Transform " ' Menu$(2)=" Defaults " For C1=0 To DFS MXL=Max(MXL,1+Len(DEFNAME$(C1))) Next For C1=0 To DFS Menu$(2,C1+1)=" "+DEFNAME$(C1)+Space$(MXL-Len(DEFNAME$(C1))) Next Menu On On Menu Proc _PROCESS,_DEFAULTS On Menu On End Proc Procedure _SETDEFAULTS Restore DEFDAT For C1=0 To DFS Read DEFNAME$(C1) For C2=0 To 15 Read DEF(C1,C2) Next Next ' DEFDAT: Data "Normal" Data 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 Data "Negative " Data 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 Data "Posterize" Data 0,0,0,0,5,5,5,5,10,10,10,10,15,15,15,15 Data "Inc Contrast" Data 0,0,0,0,0,0,3,6,9,12,15,15,15,15,15,15 Data "Lower Contrast" Data 4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11 Data "Inc Brightness" Data 8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15 Data "Lower Brightness" Data 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7 End Proc ' Procedure _PROCESS If Choice(2)=1 Screen 0 TRANSFORM_COLOR End If On Menu On End Proc Procedure _DEFAULTS C1=Choice(2) For C2=0 To 15 CL(C2)=DEF(C1-1,C2) Next CURVE_SHOW On Menu On End Proc