📄 papfiltergui.cpp
字号:
#include "stdio.h"
#include "stdlib.h"
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <windows.h>
#include <conio.h>
#include "PapFilterGUI.h"
#include "PapFilter.h"
#include "Resource.h"
#include "MainGUI.h"
#include "TexCommander.h"
#include <commctrl.h>
tTC_XORMAP C1,C1Temp;
tTC_TWIST C2,C2Temp;
tTC_MIXPICS CMix,CMixTemp;
tTC_MAKETILEABLE MT,MTTemp;
tTC_TWIRL CTW,CTWTemp;
tTC_COLOR CCol,CColTemp;
tTC_RANGECOLORS CRC,CRCTemp;
tTC_SOLIDFILL CSF,CSFTemp;
tTC_SPHERE CS,CSTemp;
tTC_TEXT CT,CTTemp;
// Process Window Message Callbacks
BOOL CALLBACK TextProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
bool MakePreview=false;
switch(uMsg)
{
case WM_INITDIALOG:
SetDlgItemText(hWnd,IDC_EDITTEXT,CT.DaText);
SendDlgItemMessage(hWnd,IDC_XSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_YSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_XSLIDER,TBM_SETPOS,true,CT.X);
SendDlgItemMessage(hWnd,IDC_YSLIDER,TBM_SETPOS,true,CT.Y);
SendDlgItemMessage(hWnd,IDC_ROTSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_GREENSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_BLAUSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_VISSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_ROTSLIDER,TBM_SETPOS,true,CT.R);
SendDlgItemMessage(hWnd,IDC_GREENSLIDER,TBM_SETPOS,true,CT.G);
SendDlgItemMessage(hWnd,IDC_BLAUSLIDER,TBM_SETPOS,true,CT.B);
SendDlgItemMessage(hWnd,IDC_VISSLIDER,TBM_SETPOS,true,CT.Trans);
CTTemp=CT;
return false;
break;
case WM_HSCROLL:
CT.R=SendDlgItemMessage(hWnd,IDC_ROTSLIDER,TBM_GETPOS,0,0);
CT.G=SendDlgItemMessage(hWnd,IDC_GREENSLIDER,TBM_GETPOS,0,0);
CT.B=SendDlgItemMessage(hWnd,IDC_BLAUSLIDER,TBM_GETPOS,0,0);
CT.Trans=SendDlgItemMessage(hWnd,IDC_VISSLIDER,TBM_GETPOS,0,0);
CT.X=SendDlgItemMessage(hWnd,IDC_XSLIDER,TBM_GETPOS,0,0);
CT.Y=SendDlgItemMessage(hWnd,IDC_YSLIDER,TBM_GETPOS,0,0);
MakePreview=true;
GetDlgItemText(hWnd,IDC_EDITTEXT,(char*)&CT.DaText,99);
CT.Len=strlen(CT.DaText);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
GetDlgItemText(hWnd,IDC_EDITTEXT,(char*)&CT.DaText,99);
CT.Len=strlen(CT.DaText);
PapDraw(Image,&CT);
EndDialog(hWnd,1);
break;
case IDCANCEL:
CT=CTTemp;
EndDialog(hWnd,0);
break;
case IDC_PREVIEW:
GetDlgItemText(hWnd,IDC_EDITTEXT,(char*)&CT.DaText,99);
CT.Len=strlen(CT.DaText);
MakePreview=true;
break;
}
break;
default:
return false;
}
if(MakePreview)
{
InitPreview();
PapDraw(TempPic,&CT);
Preview();
}
return true;
}
// Process Window Message Callbacks
BOOL CALLBACK SphereProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
bool MakePreview=false;
switch(uMsg)
{
case WM_INITDIALOG:
SendDlgItemMessage(hWnd,IDC_MINSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_MAXSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_TYPESLIDER,TBM_SETRANGE,true,MAKELONG(0,1));
SendDlgItemMessage(hWnd,IDC_MINSLIDER,TBM_SETPOS,true,CS.MinValue);
SendDlgItemMessage(hWnd,IDC_MAXSLIDER,TBM_SETPOS,true,CS.MaxValue);
SendDlgItemMessage(hWnd,IDC_TYPESLIDER,TBM_SETPOS,true,CS.Type);
switch(CS.Channel) {
case 0: CheckDlgButton(hWnd,IDC_RADIO1,BST_CHECKED); break;
case 1: CheckDlgButton(hWnd,IDC_RADIO2,BST_CHECKED); break;
case 2: CheckDlgButton(hWnd,IDC_RADIO3,BST_CHECKED); break;
case 3: CheckDlgButton(hWnd,IDC_RADIO4,BST_CHECKED); break;
case 4: CheckDlgButton(hWnd,IDC_RADIO5,BST_CHECKED); break;
}
CSTemp=CS;
return false;
break;
case WM_HSCROLL:
CS.MinValue=SendDlgItemMessage(hWnd,IDC_MINSLIDER,TBM_GETPOS,0,0);
CS.MaxValue=SendDlgItemMessage(hWnd,IDC_MAXSLIDER,TBM_GETPOS,0,0);
CS.Type=SendDlgItemMessage(hWnd,IDC_TYPESLIDER,TBM_GETPOS,0,0);
MakePreview=true;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
Sphere(Image,&CS);
EndDialog(hWnd,1);
break;
case IDC_CANCEL:
CS=CSTemp;
EndDialog(hWnd,0);
break;
case IDC_RADIO1:CS.Channel=0;MakePreview=true;break;
case IDC_RADIO2:CS.Channel=1;MakePreview=true;break;
case IDC_RADIO3:CS.Channel=2;MakePreview=true;break;
case IDC_RADIO4:CS.Channel=3;MakePreview=true;break;
case IDC_RADIO5:CS.Channel=4;MakePreview=true;break;
}
break;
default:
return false;
}
if(MakePreview)
{
InitPreview();
Sphere(TempPic,&CS);
Preview();
}
return true;
}
// Process Window Message Callbacks
BOOL CALLBACK SolidFillProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
bool MakePreview=false;
switch(uMsg)
{
case WM_INITDIALOG:
SendDlgItemMessage(hWnd,IDC_VALUESLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_VALUESLIDER,TBM_SETPOS,true,CSF.Value);
switch(CSF.Channel) {
case 0: CheckDlgButton(hWnd,IDC_RADIO1,BST_CHECKED); break;
case 1: CheckDlgButton(hWnd,IDC_RADIO2,BST_CHECKED); break;
case 2: CheckDlgButton(hWnd,IDC_RADIO3,BST_CHECKED); break;
case 3: CheckDlgButton(hWnd,IDC_RADIO4,BST_CHECKED); break;
case 4: CheckDlgButton(hWnd,IDC_RADIO5,BST_CHECKED); break;
}
CSFTemp=CSF;
return false;
break;
case WM_HSCROLL:
CSF.Value=SendDlgItemMessage(hWnd,IDC_VALUESLIDER,TBM_GETPOS,0,0);
MakePreview=true;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
SolidFill(Image,&CSF);
EndDialog(hWnd,1);
break;
case IDC_CANCEL:
CSF=CSFTemp;
EndDialog(hWnd,0);
break;
case IDC_RADIO1:CSF.Channel=0;MakePreview=true;break;
case IDC_RADIO2:CSF.Channel=1;MakePreview=true;break;
case IDC_RADIO3:CSF.Channel=2;MakePreview=true;break;
case IDC_RADIO4:CSF.Channel=3;MakePreview=true;break;
case IDC_RADIO5:CSF.Channel=4;MakePreview=true;break;
}
break;
default:
return false;
}
if(MakePreview)
{
InitPreview();
SolidFill(TempPic,&CSF);
Preview();
}
return true;
}
// Process Window Message Callbacks
BOOL CALLBACK ColorProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
bool MakePreview=false;
switch(uMsg)
{
case WM_INITDIALOG:
SendDlgItemMessage(hWnd,IDC_ROTSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_GREENSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_BLAUSLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_ALPHASLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_GAMMASLIDER,TBM_SETRANGE,true,MAKELONG(0,255));
SendDlgItemMessage(hWnd,IDC_ROTSLIDER,TBM_SETPOS,true,CCol.R);
SendDlgItemMessage(hWnd,IDC_GREENSLIDER,TBM_SETPOS,true,CCol.G);
SendDlgItemMessage(hWnd,IDC_BLAUSLIDER,TBM_SETPOS,true,CCol.B);
SendDlgItemMessage(hWnd,IDC_ALPHASLIDER,TBM_SETPOS,true,CCol.A);
SendDlgItemMessage(hWnd,IDC_GAMMASLIDER,TBM_SETPOS,true,CCol.Gamma);
switch(CCol.Channel) {
case 0: CheckDlgButton(hWnd,IDC_RADIO1,BST_CHECKED); break;
case 1: CheckDlgButton(hWnd,IDC_RADIO2,BST_CHECKED); break;
case 2: CheckDlgButton(hWnd,IDC_RADIO3,BST_CHECKED); break;
case 3: CheckDlgButton(hWnd,IDC_RADIO4,BST_CHECKED); break;
case 4: CheckDlgButton(hWnd,IDC_RADIO5,BST_CHECKED); break;
}
CColTemp=CCol;
return false;
break;
case WM_HSCROLL:
CCol.R=SendDlgItemMessage(hWnd,IDC_ROTSLIDER,TBM_GETPOS,0,0);
CCol.G=SendDlgItemMessage(hWnd,IDC_GREENSLIDER,TBM_GETPOS,0,0);
CCol.B=SendDlgItemMessage(hWnd,IDC_BLAUSLIDER,TBM_GETPOS,0,0);
CCol.A=SendDlgItemMessage(hWnd,IDC_ALPHASLIDER,TBM_GETPOS,0,0);
CCol.Gamma=SendDlgItemMessage(hWnd,IDC_GAMMASLIDER,TBM_GETPOS,0,0);
MakePreview=true;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
Color(Image,&CCol);
EndDialog(hWnd,1);
break;
case IDC_CANCEL:
CCol=CColTemp;
EndDialog(hWnd,0);
break;
case IDC_RADIO1:CCol.Channel=0;MakePreview=true;break;
case IDC_RADIO2:CCol.Channel=1;MakePreview=true;break;
case IDC_RADIO3:CCol.Channel=2;MakePreview=true;break;
case IDC_RADIO4:CCol.Channel=3;MakePreview=true;break;
case IDC_RADIO5:CCol.Channel=4;MakePreview=true;break;
}
break;
default:
return false;
}
if(MakePreview)
{
InitPreview();
Color(TempPic,&CCol);
Preview();
}
return true;
}
// Process Window Message Callbacks
BOOL CALLBACK RangeColorsProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -