%ffp //------------------------------------- // FM_TEMPLATE_4 //------------------------------------- Category: "DrTOtalREC's Filters" Title: "Image FM_Template_4" Copyright: "Copyright ©2001" Author: "Ron Chambers" Organization: "DrTOtalREC Filters, Inc." Filename: "fm_template_4" Description: "Image FM_Template_4" Version: "v1.0 (08/31/2001)" URL: "mailto://rfchmbrs@swbell.net" About: "DrTOtalREC's Image FM_Template_4 !V\n" "!c\n!A\n!U" Dialog: Text = "DrTOtalREC's Image FM_Template_4 !V !c !A", Color=darkblue, Gradient = ( midnightblue, mediumblue, v ) //------------------------------------- SupportedModes: RGBMode //------------------------------------- // OnFilterStart //------------------------------------- OnFilterStart: { const int BS_NOTIFY = 0x00004000; const int CTP_MOUSEOVER = 0x00000200; int ui_x, ui_y, ui_dx, ui_dy, ii, ij; bool diag; bool fAbs=1; //------ if( imageMode != RGBMode ) { ErrorOk("This filter only works on RGB images."); doAction(CA_CANCEL); } //------------------------------------- // build first part of gui //------------------------------------- if(k9==0) { k9 = 1; //------ ui_dx = 36; ui_dy = 10; ui_x = 400 + ui_dx; ui_y = (ui_dy+2) * 20; setDialogPos (fAbs, -1, -1, ui_x, ui_y); //------------------------------------- diag = false; if(enableCtl(CTL_EDIT, 3)==3) { diag = true; k9 = 2; } //------------------------------------- ij = -1; ui_dx = 120; ui_dy = 10; ui_x = 275; ui_y = -ui_dy; //------ ij++; ui_y += ui_dy+8; snprintf( str9[0], 21, "%s", "Slider (Range 0-255) "); snprintf( str9[21], 1, "%s", ""); createCtl(ij, CC_STANDARD, str9, ui_x, ui_y, ui_dx, ui_dy, 0, 0, 0, -1); setCtlRange(ij, 00, 255); setCtlVal(ij, 02); setCtlAction(ij, CA_NONE); setCtlToolTip(ij, str9, 0); //------ ij++; ui_y += ui_dy+2; snprintf( str9[0], 20, "%s", "Checkbox "); snprintf( str9[20], 1, "%s", ""); createCtl(ij, CC_CHECKBOX, str9, ui_x, ui_y, ui_dx, ui_dy, 3, 0, 0, -1); setCtlVal(ij, 1); setCtlAction(ij, CA_NONE); setCtlToolTip(ij, str9, 0); //------------------------------------- // build second part of gui //------------------------------------- ui_dx = 36; ui_x = ui_dx; ui_y = 180; createCtl(113, CC_PUSHBUTTON, "Preview", ui_x,ui_y, ui_dx, ui_dy, BS_NOTIFY, 0, CTP_MOUSEOVER, 3); setCtlAction(113, CA_PREVIEW); setCtlToolTip(113, "Preview-shows the effects on the image in the preview window.", 0); //------ ui_x += ui_dx+2; createCtl(115, CC_PUSHBUTTON, "Reset", ui_x,ui_y, ui_dx, ui_dy, BS_NOTIFY, 0, CTP_MOUSEOVER, 3); setCtlAction(115, CA_NONE); setCtlToolTip(115, "Resets the preview window and parameters.", 0); //------ ui_x += ui_dx+2; createCtl(CTL_OK, CC_PUSHBUTTON, "Apply", ui_x,ui_y, ui_dx, ui_dy, BS_NOTIFY, 0, CTP_MOUSEOVER, 3); setCtlAction(CTL_OK, CA_APPLY); setCtlToolTip(CTL_OK, "Apply-applies the parameters to the image.", 0); //------ ui_x = ui_dx; ui_y += ui_dy+2; createCtl(114, CC_PUSHBUTTON, "Help", ui_x,ui_y, ui_dx, ui_dy, BS_NOTIFY, 0, CTP_MOUSEOVER, 3); setCtlAction(114, CA_NONE); setCtlToolTip(114, "HELP-help file is displayed in the Internet browser.", 0); //------ ui_x += ui_dx+2; createCtl(CTL_CANCEL, CC_PUSHBUTTON, "Cancel", ui_x,ui_y, ui_dx, ui_dy, BS_NOTIFY, 0, CTP_MOUSEOVER, 3); setCtlAction(CTL_CANCEL, CA_CANCEL); setCtlToolTip(CTL_CANCEL, "Cancel-cancels the action and returns to the image processing program.", 0); //------ ui_x += ui_dx+2; createCtl(CTL_LOGO, CC_PUSHBUTTON, "About", ui_x,ui_y, ui_dx, ui_dy, BS_NOTIFY, 0, CTP_MOUSEOVER, 3); setCtlAction(CTL_LOGO, CA_ABOUT); setCtlToolTip(CTL_LOGO, "About-shows in the About window filter and author information.", 0); } //------------------------------------- // end building gui //------------------------------------- return false; }//OnFilterStart //------------------------------------- // ForEveryTile //------------------------------------- ForEveryTile: { int iVal, ij; int XZ; int Zend; int range; bool check; int cost, total_cost; //------------------------------------- // Initialize variables //------------------------------------- ij = 0; range = ctl(ij++); check = ctl(ij++); Zend = Z; if (imageMode == RGBMode) Zend = RGBMode; //------------------------------------- // cost function //------------------------------------- XZ = (x_end-x_start+1) * Z; total_cost = XZ * (y_end-y_start+1) * (1 + Z - Zend); cost = 0; //------------------------------------- // place data in iVal and then iVal in output //------------------------------------- for (y= y_start; y < y_end; y++) { for (x = x_start; x < x_end; x++) { for (z = 0; z