%ffp /* ================================================================== Filter information ================================================================== */ Category :"Color Mapping" Title :"Transparency" Copyright :"Freeware" Author :"Wm. G. MacBeth" Filename :"Transparency.8bf" Description:"Sets the transparency in areas of a selected color." Version :"1.0a1" About :"!T !V\n!D\n" "!c\n" Dialog :color=#C0C0C0 /* ================================================================== Dialog information ================================================================== */ ctl[CTL_LOGO]: none ctl(0): statictext(staticedge)," Color Selection", position=(185,4),size=(181,83), color=#C0C0C0,fontcolor=black ctl(1): pushbutton,pos=(245,15),size=(75,*), text="Center Color Picker",fontcolor=#000000 ctl(2): scrollbar,pos=(235,75), range=(0,wholeWidth),val=wholeWidth/2 ctl(3): scrollbar(vert),pos=(225,15),size=(*,60), range=(0,wholeHeight),val=wholeHeight/2 ctl(4): ownerdraw(staticedge),pos=(245,40),size=(25,20) ctl(5): statictext(right),fontcolor=#000000,text="R", pos=(280,37),size=(10,*) ctl(6): statictext(staticedge,right), pos=(295,37),size=(25,*), fontcolor=#000000,color=#C0C0C0 ctl(7): statictext(right),fontcolor=#000000,text="G", pos=(280,47),size=(10,*) ctl(8): statictext(staticedge,right), pos=(295,47),size=(25,*), fontcolor=#000000,color=#C0C0C0 ctl(9): statictext(right),fontcolor=#000000,text="B", pos=(280,57),size=(10,*) ctl(10): statictext(staticedge,right), pos=(295,57),size=(25,*), fontcolor=#000000,color=#C0C0C0 ctl(20): statictext(staticedge)," Transparency", position=(185,91),size=(181,24), color=#C0C0C0,fontcolor=black ctl(22): standard,position=(235,100), range=(0,255),val=1 ctl(40): checkbox(staticedge),pos=(115,115),size=(51,10), text=" Preview",fontcolor=#000000 ctl(50): pushbutton(notify),pos=(181,126), // Help pushbutton text="Help",fontcolor=#000000 ctl(58): pushbutton(notify),pos=(218,126), // About pushbutton text="About",fontcolor=#000000 /* ================================================================== Image Handler ================================================================== */ ForEveryTile: { // Variable declarations int xpos; int ypos; int rsel; int gsel; int bsel; int alpha; int ccolor; // Update dialog title setDialogText(" Transparency"); // Show Error and cancel execution if alpha channel not present if ( Z<4 ) { updateProgress(0,1); msgBox(MB_ICONERROR," Error", "This filter requires that an alpha channel be\n" "present in the image. Add an alpha channel\n" "from the host image program."); // doAction(CA_CANCEL); } // Handle click on Help pushbutton if ( ctl(50)==1 ) { setCtlVal(50,0); msgBox(MB_ICONINFORMATION,"Help for Transparency", "Use the Color Selection controls to select a region\n" "that will have its transparency modified.\n" "\n" "Set the desired value of transparancy for that color\n" "with the Transparency slider.\n" " (0 = transparent to 255 = opaque)\n"); } // Handle click on About Button if ( ctl(58)==true ) { setCtlVal(58,false); // Clear the event msgBox(MB_OK,"About Transparency", "\n" "!T !V\n" "!D\n" "!c"); enableCtl(59,-1); } // Update the variables and controls setCtlPageSize(2,columns*scaleFactor/24); setCtlPageSize(3,rows*scaleFactor/17); xpos = ctl(2)/scaleFactor; ypos = ctl(3)/scaleFactor; rsel = src(xpos,ypos,0); gsel = src(xpos,ypos,1); bsel = src(xpos,ypos,2); setCtlColor(4,RGB(rsel,gsel,bsel)); setCtlTextv(6,"%d ",rsel); setCtlTextv(8,"%d ",gsel); setCtlTextv(10,"%d ",bsel); alpha = ctl(22); // Handle the Center Color Picker pushbutton if ( ctl(1)==true ) { setCtlVal(1,false); setCtlVal(2,(x_end+x_start)*scaleFactor/2); setCtlVal(3,(y_end+y_start)*scaleFactor/2); xpos = ctl(2)/scaleFactor; ypos = ctl(3)/scaleFactor; } // Code for Color Picker in the preview window if (doingProxy==true && Z==4 ) { // Draw the horizontal part of the cross hair for ( x=xpos-8; x<=xpos+8; x++ ) { if ( abs(x-xpos)>4 || x==xpos ) { if ( scl(src(x,ypos,3),0,255,450, src(x,ypos,0)+src(x,ypos,1))<256 ) { ccolor = 255; } else { ccolor = 0; } for (z=0; z4 ) { if ( scl(src(x,ypos,3),0,255,450, src(x,ypos,0)+src(x,ypos,1))<256 ) { ccolor = 255; } else { ccolor = 0; } for (z=0; z