#include "ImgPF.h" static L_BOOL Plasma_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam); static L_BOOL Plasma_OnCommand(HWND hDlg, L_INT id, HWND hwndCtl, UINT codeNotify); static L_BOOL Plasma_OnHScroll(HWND hWnd, HWND hWndCtl, L_UINT nCode, L_INT nPos); static L_VOID L_ApplyFilter(HWND hWnd); L_BOOL CALLBACK PlasmaWndProc (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { switch (uMessage) { HANDLE_MSG (hWnd, WM_INITDIALOG, Plasma_OnInitDialog); HANDLE_MSG (hWnd, WM_COMMAND, Plasma_OnCommand); HANDLE_MSG (hWnd, WM_HSCROLL, Plasma_OnHScroll); case WM_USER_UPDATEVIEW: StatusProc.ProgressValue = 100; L_ApplyFilter (hWnd); break; } return FALSE; } static L_BOOL Plasma_OnInitDialog(HWND hWnd, HWND hwndFocus, LPARAM lParam) { HWND hWndParent; pCHILDDATA pData; LPPLASMADATA pPlasmaData; L_INT nRangeMin[] = {0, 1, 0, 0, 0, 0}; L_INT nRangeMax[] = {255, 1000, 100, 255, 255, 255}; L_INT nPosInit[] = {0, 1, 50, 128, 128, 128}; L_INT nSlider; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); pPlasmaData = (LPPLASMADATA)lParam; MoveDialogToMiddle(hWnd); SetWindowLong(hWnd,GWL_USERDATA,(LONG)pPlasmaData); //MEMDISK...// MemorizeAndCopyBitmap (hWndParent, &pPlasmaData->hBitmap); pPlasmaData->uPlasmaType = PLSTYP_VERTICAL; pPlasmaData->uPaletteType = PLSCLR_HUE; Progress_SetRange(StatusProc.ProgWnd, 0, 100); Progress_SetPos(StatusProc.ProgWnd, 0); StatusProc.bProgress = TRUE; StatusProc.bInvalidate = FALSE; StatusProc.bEnd = FALSE; StatusProc.DlgWnd = hWnd; StatusProc.ProgressValue = 100; StatusProc.ProgWnd = GetDlgItem(hWnd, IDC_PLASMA_PRGRS); pPlasmaData->nSlideNum = 6; pPlasmaData->nEdtBaseID = IDC_PLASMA_SHFT_EDT; pPlasmaData->nSldBaseID = IDC_PLASMA_SHFT_SLD; pPlasmaData->PlasmaInfo.uShift = nPosInit[0]; pPlasmaData->PlasmaInfo.uSize = nPosInit[1]; pPlasmaData->PlasmaInfo.uOpacity = nPosInit[2]; pPlasmaData->PlasmaInfo.uRedFreq = nPosInit[3]; pPlasmaData->PlasmaInfo.uGreenFreq = nPosInit[4]; pPlasmaData->PlasmaInfo.uBlueFreq = nPosInit[5]; pPlasmaData->PlasmaInfo.uFlags = 0; for (nSlider = 0; nSlider < pPlasmaData->nSlideNum; nSlider++) { Trackbar_SetRange (GetDlgItem(hWnd, pPlasmaData->nSldBaseID + nSlider), TRUE, nRangeMin[nSlider], nRangeMax[nSlider]); SetNumericEditBox(GetDlgItem(hWnd, pPlasmaData->nEdtBaseID + nSlider), nRangeMin[nSlider], nRangeMax[nSlider], 1, 0, FALSE); SetDlgItemInt (hWnd, pPlasmaData->nEdtBaseID + nSlider, nPosInit[nSlider], FALSE); } ComboBox_AddString(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), TEXT("Vertical")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), TEXT("Horizontal")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), TEXT("Diagonal")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), TEXT("Cross")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), TEXT("Circular")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), TEXT("Random 1")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), TEXT("Random 2")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB), 0); ComboBox_AddString(GetDlgItem(hWnd, IDC_PALETTE_TYPE_CMB), TEXT("Color Mix 1")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PALETTE_TYPE_CMB), TEXT("Color Mix 2")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PALETTE_TYPE_CMB), TEXT("Color Mix 3")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PALETTE_TYPE_CMB), TEXT("Custom")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_PALETTE_TYPE_CMB), 0); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_RED_EDT), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_GRN_EDT), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_BLU_EDT), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_RED_SLD), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_GRN_SLD), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_BLU_SLD), pPlasmaData->uPaletteType == 3); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); L_ApplyFilter (hWnd); return TRUE; } static L_BOOL Plasma_OnCommand(HWND hWnd, L_INT nID, HWND hwndCtl, UINT uCodeNotify) { L_UINT uValue; LPPLASMADATA pPlasmaData = (LPPLASMADATA) GetWindowLong (hWnd, GWL_USERDATA); switch (nID) { case IDOK: ShowStatusWindow(FALSE); StatusProc.bStillWork = TRUE; StatusProc.bInvalidate = TRUE; StatusProc.bEnd = TRUE; EndDialog(hWnd, TRUE); break; case IDCANCEL: StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE; StatusProc.ProgressValue = 100; EndDialog(hWnd, FALSE); break; case IDC_PLASMA_TYPE_CMB: if (uCodeNotify == CBN_SELCHANGE) { L_UINT nIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_PLASMA_TYPE_CMB)); if (pPlasmaData->uPlasmaType == nIndex) return TRUE; pPlasmaData->uPlasmaType = nIndex; pPlasmaData->PlasmaInfo.uFlags = (pPlasmaData->uPaletteType << 4) | pPlasmaData->uPlasmaType; L_ApplyFilter (hWnd); } break; case IDC_PALETTE_TYPE_CMB: if (uCodeNotify == CBN_SELCHANGE) { L_UINT nIndex = (ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_PALETTE_TYPE_CMB))); if (pPlasmaData->uPaletteType == nIndex) return TRUE; pPlasmaData->uPaletteType = nIndex; pPlasmaData->PlasmaInfo.uFlags = (pPlasmaData->uPaletteType << 4) | pPlasmaData->uPlasmaType; EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_RED_EDT), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_GRN_EDT), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_BLU_EDT), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_RED_SLD), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_GRN_SLD), pPlasmaData->uPaletteType == 3); EnableWindow(GetDlgItem(hWnd, IDC_PLASMA_BLU_SLD), pPlasmaData->uPaletteType == 3); L_ApplyFilter (hWnd); } break; } if (nID >= pPlasmaData->nEdtBaseID && nID < pPlasmaData->nEdtBaseID + pPlasmaData->nSlideNum) { L_INT nIndex = nID - pPlasmaData->nEdtBaseID; uValue = GetDlgItemInt(hWnd, nID, NULL, TRUE); Trackbar_SetPos(GetDlgItem(hWnd, nID + pPlasmaData->nSlideNum), TRUE, uValue); switch(nIndex) { case 0: if (pPlasmaData->PlasmaInfo.uShift == uValue) return TRUE; pPlasmaData->PlasmaInfo.uShift = uValue; break; case 1: if (pPlasmaData->PlasmaInfo.uSize == uValue) return TRUE; pPlasmaData->PlasmaInfo.uSize = uValue; break; case 2: if (pPlasmaData->PlasmaInfo.uOpacity == uValue) return TRUE; pPlasmaData->PlasmaInfo.uOpacity = uValue; break; case 3: if (pPlasmaData->PlasmaInfo.uRedFreq == uValue) return TRUE; pPlasmaData->PlasmaInfo.uRedFreq = uValue; break; case 4: if (pPlasmaData->PlasmaInfo.uGreenFreq == uValue) return TRUE; pPlasmaData->PlasmaInfo.uGreenFreq = uValue; break; case 5: if (pPlasmaData->PlasmaInfo.uBlueFreq == uValue) return TRUE; pPlasmaData->PlasmaInfo.uBlueFreq = uValue; break; } L_ApplyFilter(hWnd); } return TRUE; } static L_BOOL Plasma_OnHScroll(HWND hWnd, HWND hWndCtl, L_UINT nCode, L_INT nPos) { LPPLASMADATA pPlasmaData = (LPPLASMADATA) GetWindowLong(hWnd, GWL_USERDATA); return SetDlgItemInt(hWnd, GetDlgCtrlID(hWndCtl) - pPlasmaData->nSlideNum , Trackbar_GetPos(hWndCtl), TRUE); } static L_VOID L_ApplyFilter (HWND hWnd) { L_INT nRet; HWND hWndParent; pCHILDDATA pData; LPPLASMADATA pPlasmaData; pPlasmaData = (LPPLASMADATA) GetWindowLong(hWnd,GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); if ( 100 != StatusProc.ProgressValue ) { StatusProc.bKillProgress = TRUE; return; } FreeMemorizedBitmap (hWndParent); //MEMDISK// L_CopyBitmap(&pData->LeadBitmap, &pPlasmaData->hBitmap, sizeof(BITMAPHANDLE)); pPlasmaData->PlasmaInfo.uStructSize = sizeof(PLASMAINFO); nRet = L_PlasmaFilterBitmap(&pData->LeadBitmap, &pPlasmaData->PlasmaInfo); if(nRet == SUCCESS) { InvalidateRect(hWndParent, NULL, FALSE); StatusProc.ProgressValue = 100; Progress_SetPos(StatusProc.ProgWnd , 0); if(StatusProc.bEnd) { StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE; } } }