/*[]=====================================================================[]*/ /*[] LeadTools Run Time Library - Version 14 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2004 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ #include "ImgPF.h" static L_BOOL DtnDlg_OnPaint (HWND); static L_BOOL DtnDlg_OnInitDialog (HWND, HWND, LPARAM); static L_BOOL DtnDlg_OnMouseMove (HWND, L_INT, L_INT, UINT); static L_BOOL DtnDlg_OnLButtonDown (HWND, BOOL , L_INT, L_INT, UINT); static L_BOOL DtnDlg_OnRButtonDown (HWND hWnd, L_BOOL fDoubleClick, L_INT nX, L_INT nY, L_UINT ukeyFlags); static L_BOOL DtnDlg_OnLButtonUp (HWND, L_INT, L_INT, UINT); static L_BOOL DtnDlg_OnCommand (HWND, int, HWND, UINT); static L_VOID DtnDlg_OnTimer (HWND hWnd, L_INT nID); static L_VOID MakeGradient (HWND hWnd); static L_VOID ShowClrDialog (HWND hWnd, L_INT); static L_VOID L_ApplyFilter (HWND hWnd); L_BOOL CALLBACK LkDialog(HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { static L_VOID InitPolygon (HWND hWnd, LPDTNDLGDATA pDtnDlgData); static L_VOID GetLookTable (HWND hWnd, LPDTNDLGDATA pDtnDlgData); static L_VOID AddArrayPoint (L_INT nX, L_INT nY, LPDTNDLGDATA pDtnDlgData); static L_BOOL ChangeUserPoints (L_INT nX, L_INT nY, L_INT Point, LPDTNDLGDATA pDtnDlgData); static L_VOID DeleteUserPoint (L_INT nX, L_INT nY, L_INT Point, LPDTNDLGDATA pDtnDlgData); static L_VOID GetTable (HWND hWnd); static L_VOID GetFunctinalTable (HWND hWnd, L_BOOL bInit, LPDTNDLGDATA pDtnDlgData); switch (uMessage) { HANDLE_MSG (hWnd, WM_PAINT, DtnDlg_OnPaint); HANDLE_MSG (hWnd, WM_INITDIALOG, DtnDlg_OnInitDialog); HANDLE_MSG (hWnd, WM_MOUSEMOVE, DtnDlg_OnMouseMove); HANDLE_MSG (hWnd, WM_LBUTTONDOWN, DtnDlg_OnLButtonDown); HANDLE_MSG (hWnd, WM_LBUTTONUP, DtnDlg_OnLButtonUp); HANDLE_MSG (hWnd, WM_COMMAND, DtnDlg_OnCommand); HANDLE_MSG (hWnd, WM_RBUTTONDOWN, DtnDlg_OnRButtonDown); HANDLE_MSG (hWnd, WM_TIMER, DtnDlg_OnTimer); case WM_USER_UPDATEVIEW: StatusProc.ProgressValue = 100; GetTable(hWnd); break; } return 0; } static L_BOOL DtnDlg_OnInitDialog(HWND hWnd, HWND hwndFocus, LPARAM lParam) { pCHILDDATA pData; HWND hWndParent; L_INT nCount; RECT Rect; LPDTNDLGDATA pDtnDlgData; L_UINT uMem; L_INT nRet; pDtnDlgData = (LPDTNDLGDATA)lParam; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); SetWindowLong(hWnd, GWL_USERDATA, (LONG)pDtnDlgData); //MEMDISK...// MemorizeAndCopyBitmap (hWndParent, &pDtnDlgData->Bitmap); MakeRectangleWindow(hWnd, IDC_DTN_CRV_TXT); L_CopyBitmap(&pDtnDlgData->BackUpGray, &pDtnDlgData->Bitmap, sizeof(BITMAPHANDLE)); if (pDtnDlgData->BackUpGray.BitsPerPixel < 8 ) nRet = L_GrayScaleBitmap(&pDtnDlgData->BackUpGray, 8); else nRet = L_GrayScaleBitmapExt(&pDtnDlgData->BackUpGray, 250, 625, 125); nRet = SUCCESS; if (nRet != SUCCESS) return FALSE; InvalidateRect(hWndParent, NULL, FALSE); pDtnDlgData->nPercentage = 100; StatusProc.bProgress = TRUE; StatusProc.bInvalidate = FALSE; StatusProc.bEnd = FALSE; StatusProc.DlgWnd = hWnd; StatusProc.ProgressValue = 100; StatusProc.ProgWnd = GetDlgItem(hWnd, IDC_DTN_PROG); MoveDialogToMiddle(hWnd); Progress_SetRange(StatusProc.ProgWnd, 0, 100); Progress_SetPos(StatusProc.ProgWnd, 0); //MEMDISK...// L_GetBitmapMemoryInfo (&pData->LeadBitmap, &uMem, NULL, NULL, NULL, NULL, NULL); if (uMem == TYPE_CONV) L_FreeBitmap (&pData->LeadBitmap); L_CopyBitmap(&pData->LeadBitmap, &pDtnDlgData->BackUpGray, sizeof(BITMAPHANDLE)); ComboBox_AddString(GetDlgItem(hWnd, IDC_DTN_CLR_COM), TEXT("Monotone")); ComboBox_AddString(GetDlgItem(hWnd, IDC_DTN_CLR_COM), TEXT("Duotone")); ComboBox_AddString(GetDlgItem(hWnd, IDC_DTN_CLR_COM), TEXT("Tritone")); ComboBox_AddString(GetDlgItem(hWnd, IDC_DTN_CLR_COM), TEXT("Quadtone")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_DTN_CLR_COM), 0); ComboBox_AddString(GetDlgItem(hWnd, IDC_DTN_OPR_COM), TEXT("Exp")); ComboBox_AddString(GetDlgItem(hWnd, IDC_DTN_OPR_COM), TEXT("Ln")); ComboBox_AddString(GetDlgItem(hWnd, IDC_DTN_OPR_COM), TEXT("Linear")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_DTN_OPR_COM), 2); pDtnDlgData->Color[0] = RGB( 0, 0, 0); pDtnDlgData->Color[1] = RGB(255, 255, 255); pDtnDlgData->Color[2] = RGB(255, 255, 255); pDtnDlgData->Color[3] = RGB(255, 255, 255); pDtnDlgData->bOper = TRUE; InitPolygon (hWnd, pDtnDlgData); MakeRectangleWindow(hWnd, IDC_DTN_CRV_TXT); //MoveWindow (GetDlgItem(hWnd, IDC_DTN_CRV_TXT), 10, 10, 186, 186, TRUE); GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); pDtnDlgData->pCurveTable = (L_UINT L_FAR *)malloc((Rect.right - Rect.left + 1) * sizeof(L_UINT)); pDtnDlgData->uLUTLen = 255; for(nCount = 0; nCount < 4; nCount++) { pDtnDlgData->pRGBArray[nCount] = (LPRGBQUAD) malloc(sizeof(RGBQUAD) * 256); } for(nCount = 0; nCount <= 3; nCount++) { pDtnDlgData->uLut[nCount] = (L_UINT L_FAR *)malloc((pDtnDlgData->uLUTLen + 1) * sizeof(L_UINT)); pDtnDlgData->ChanData[nCount].bOper = TRUE; pDtnDlgData->ChanData[nCount].nFactor = 1; pDtnDlgData->ChanData[nCount].nOper= 2; pDtnDlgData->aptCurve[nCount] = (POINT L_FAR *)malloc((Rect.right - Rect.left + 1)* 2 *sizeof(LONG)); pDtnDlgData->nIndex = nCount; pDtnDlgData->nUserPntCnt[nCount] = 2; GetFunctinalTable(hWnd, TRUE, pDtnDlgData); } pDtnDlgData->nIndex = 0; Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), FALSE); SetDlgItemInt (hWnd, IDC_DTN_FCTR_TXT, 1, TRUE); //SetNumericEditBox(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), -100, 100, 1, 0, 0); pData->uTimerID = SetTimer(hWnd, 1, 100, NULL); UNLOCKCHILDDATA(hWndParent); return TRUE; } static L_VOID DtnDlg_OnTimer(HWND hWnd, L_INT nID) { Dialog_Timer(nID); } static L_BOOL DtnDlg_OnRButtonDown (HWND hWnd, L_BOOL fDoubleClick, L_INT nX, L_INT nY, L_UINT ukeyFlags) { RECT Rect; POINT TmpPoint; HBRUSH hBrush; LPDTNDLGDATA pDtnDlgData; COLORREF crColor; HDC hDC; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_ST_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_ST_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 0) { Rect.bottom = Rect.bottom - 1; Rect.top = Rect.top + 1; Rect.left = Rect.left + 1; Rect.right = Rect.right -1; crColor = pDtnDlgData->Color[0]; pDtnDlgData->Color[0] = ShowColorDialog(hWnd, crColor); if (pDtnDlgData->Color[0] != crColor) { hBrush = CreateSolidBrush(pDtnDlgData->Color[0]); hDC = GetDC(GetDlgItem(hWnd, IDC_DTN_ST_IMG)); FillRect(hDC, &Rect, hBrush); ReleaseDC(GetDlgItem(hWnd, IDC_DTN_ST_IMG), hDC); DeleteBrush(hBrush); if(!Button_GetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK))) GetFunctinalTable(hWnd, FALSE, pDtnDlgData); else { GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); } L_ApplyFilter(hWnd); InvalidateRect(hWnd, NULL, FALSE); } return FALSE; } TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_ND_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_ND_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 1) { Rect.bottom = Rect.bottom - 1; Rect.top = Rect.top + 1; Rect.left = Rect.left + 1; Rect.right = Rect.right - 1; crColor = pDtnDlgData->Color[1]; pDtnDlgData->Color[1] = ShowColorDialog(hWnd, crColor); if (pDtnDlgData->Color[1] != crColor) { hBrush = CreateSolidBrush(pDtnDlgData->Color[1]); hDC = GetDC(GetDlgItem(hWnd, IDC_DTN_ND_IMG)); FillRect(hDC, &Rect, hBrush); DeleteBrush(hBrush); ReleaseDC(GetDlgItem(hWnd, IDC_DTN_ND_IMG), hDC); if(!Button_GetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK))) GetFunctinalTable(hWnd, FALSE, pDtnDlgData); else { GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); } InvalidateRect(hWnd, NULL, FALSE); L_ApplyFilter(hWnd); } return FALSE; } TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_TH_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_TH_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 2) { Rect.bottom = Rect.bottom - 1; Rect.top = Rect.top + 1; Rect.left = Rect.left + 1; Rect.right = Rect.right - 1; crColor = pDtnDlgData->Color[2]; pDtnDlgData->Color[2] = ShowColorDialog(hWnd, crColor); if (pDtnDlgData->Color[2] != crColor) { hBrush = CreateSolidBrush(pDtnDlgData->Color[2]); hDC = GetDC(GetDlgItem(hWnd, IDC_DTN_TH_IMG)); FillRect(hDC, &Rect, hBrush); ReleaseDC(GetDlgItem(hWnd, IDC_DTN_TH_IMG), hDC); DeleteBrush(hBrush); if(!Button_GetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK))) GetFunctinalTable(hWnd, FALSE, pDtnDlgData); else { GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); } InvalidateRect(hWnd, NULL, FALSE); L_ApplyFilter(hWnd); } return FALSE; } TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_FO_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_FO_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 3) { Rect.bottom = Rect.bottom - 1; Rect.top = Rect.top + 1; Rect.left = Rect.left + 1; Rect.right = Rect.right - 1; crColor = pDtnDlgData->Color[3]; pDtnDlgData->Color[3] = ShowColorDialog(hWnd, crColor); if (pDtnDlgData->Color[3] != crColor) { hBrush = CreateSolidBrush(pDtnDlgData->Color[3]); hDC = GetDC(GetDlgItem(hWnd, IDC_DTN_FO_IMG)); FillRect(hDC, &Rect, hBrush); ReleaseDC(GetDlgItem(hWnd, IDC_DTN_FO_IMG), hDC); DeleteBrush(hBrush); if(!Button_GetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK))) GetFunctinalTable(hWnd, FALSE, pDtnDlgData); else { GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); } InvalidateRect(hWnd, NULL, FALSE); L_ApplyFilter(hWnd); } return FALSE; } return TRUE; } L_VOID DrawGrad(HWND hWnd) { HDC hDC; HWND hGradWnd; RECT rcRect; HPEN hPen; HPEN hOldPen; L_INT nCounter, nCounter1; L_UINT nRedFactor, nGreenFactor, nBlueFactor; L_UINT nRedValue, nGreenValue, nBlueValue; LPDTNDLGDATA pDtnDlgData; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); for (nCounter1 = 0; nCounter1 <= (L_INT)pDtnDlgData->ColorNum; nCounter1++) { nRedValue = GetRValue(pDtnDlgData->Color[nCounter1]); nGreenValue = GetGValue(pDtnDlgData->Color[nCounter1]); nBlueValue = GetBValue(pDtnDlgData->Color[nCounter1]); nRedFactor = ((255 - nRedValue) * 1000) / 255; nGreenFactor = ((255 - nGreenValue) * 1000) / 255; nBlueFactor = ((255 - nBlueValue) * 1000) / 255; for (nCounter = 0; nCounter < 256; nCounter++) { pDtnDlgData->pRGBArray[nCounter1][nCounter].rgbRed = nRedValue + ((nRedFactor * pDtnDlgData->uLut[nCounter1][nCounter]) / 1000); pDtnDlgData->pRGBArray[nCounter1][nCounter].rgbGreen = nGreenValue + ((nGreenFactor * pDtnDlgData->uLut[nCounter1][nCounter]) / 1000); pDtnDlgData->pRGBArray[nCounter1][nCounter].rgbBlue = nBlueValue + ((nBlueFactor * pDtnDlgData->uLut[nCounter1][nCounter]) / 1000); } } hGradWnd = (HWND) GetDlgItem(hWnd, IDC_DTN_GRAD_IMG); GetClientRect(hGradWnd, &rcRect); hDC = GetDC(hGradWnd); nCounter1 = 0; for (nCounter = 1; nCounter < /*(rcRect.right - rcRect.left)191*/(rcRect.right - rcRect.left); nCounter++) { hPen = CreatePen(0, 0, RGB(pDtnDlgData->pRGBArray[pDtnDlgData->nIndex][nCounter1].rgbRed, pDtnDlgData->pRGBArray[pDtnDlgData->nIndex][nCounter1].rgbGreen, pDtnDlgData->pRGBArray[pDtnDlgData->nIndex][nCounter1].rgbBlue)); hOldPen = SelectObject(hDC, hPen); MoveToEx(hDC, nCounter , 1, NULL); LineTo(hDC, nCounter, rcRect.bottom - 1); hPen = SelectObject(hDC, hOldPen); DeletePen(hPen); nCounter1 = (L_INT)(nCounter * 25500 / (rcRect.right - rcRect.left) + 50) / 100; } ReleaseDC(hGradWnd, hDC); } static L_BOOL DtnDlg_OnPaint(HWND hWnd) { PAINTSTRUCT ps; HDC hdc, hdcMemo, hDCRect; RECT Rect; L_INT cxClient, cyClient; HBITMAP hBitmap; HPEN hPen, hPen1; HBRUSH hbrush; L_INT nCount; L_INT nCounter; LPDTNDLGDATA pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); cxClient = Rect.right - Rect.left; cyClient = Rect.bottom - Rect.top; hdc = BeginPaint(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &ps); hBitmap = CreateCompatibleBitmap(hdc, cxClient, cyClient); hdcMemo = CreateCompatibleDC(hdc); SelectObject(hdcMemo, hBitmap); FillRect(hdcMemo, &Rect, (HBRUSH) (COLOR_WINDOW)); hPen = CreatePen(PS_SOLID, 0, RGB(30, 130, 30)); SelectObject(hdcMemo, hPen); for(nCount = 0; nCount <= 8; nCount++) { MoveToEx(hdcMemo, 1, nCount * ((cyClient-1) >> 3), NULL); LineTo(hdcMemo, nCount * (cxClient - 1), nCount * ((cyClient-1) >> 3)); } for(nCount = 0; nCount <= 8; nCount++) { MoveToEx(hdcMemo, nCount * ((cxClient - 1) >> 3), 0, NULL); LineTo(hdcMemo, nCount * ((cxClient - 1) >> 3), cyClient); } hPen1 = CreatePen(PS_SOLID, 2, pDtnDlgData->Color[pDtnDlgData->nIndex]); SelectObject(hdcMemo, hPen1); Polyline(hdcMemo, pDtnDlgData->aptCurve[pDtnDlgData->nIndex], cxClient + 1); hbrush = CreateSolidBrush(RGB(255, 255, 0)); SelectObject(hdcMemo, hbrush); if(!pDtnDlgData->bOper) { for(nCount=0;nCount<(L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex];nCount++) { Ellipse(hdcMemo, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x - 3, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y - 3, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x + 3, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y + 3); } } StretchBlt(hdc, 0, 0, cxClient, cyClient, hdcMemo, 0, 0, cxClient, cyClient, SRCCOPY); DeleteBrush(hbrush); DeletePen (hPen1); for (nCounter = 0; nCounter <= (L_INT)pDtnDlgData->ColorNum; nCounter++) { hDCRect = GetDC(GetDlgItem(hWnd, IDC_DTN_ST_IMG + nCounter)); hbrush = CreateSolidBrush(pDtnDlgData->Color[nCounter]); GetClientRect(GetDlgItem(hWnd, IDC_DTN_ST_IMG + nCounter), &Rect); Rect.bottom = Rect.bottom - 1; Rect.top = Rect.top + 1; Rect.right = Rect.right - 1; Rect.left = Rect.left + 1; FillRect(hDCRect, &Rect, hbrush); DeleteBrush(hbrush); ReleaseDC(GetDlgItem(hWnd, IDC_DTN_ST_IMG + nCounter), hDCRect); } for (nCounter = pDtnDlgData->ColorNum + 1; nCounter < 4; nCounter++) { hDCRect = GetDC(GetDlgItem(hWnd, IDC_DTN_ST_IMG + nCounter)); GetClientRect(GetDlgItem(hWnd, IDC_DTN_ST_IMG + nCounter), &Rect); Rect.bottom = Rect.bottom - 1; Rect.top = Rect.top + 1; Rect.right = Rect.right - 1; Rect.left = Rect.left + 1; FillRect(hDCRect, &Rect, (HBRUSH)COLOR_WINDOW); ReleaseDC(GetDlgItem(hWnd, IDC_DTN_ST_IMG + nCounter), hDCRect); } DrawGrad(hWnd); DeleteDC(hdcMemo); DeleteBitmap(hBitmap); DeleteObject (hPen); EndPaint(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &ps); return FALSE; } static L_BOOL DtnDlg_OnMouseMove (HWND hWnd, L_INT nX, L_INT nY, UINT keyFlags) { pCHILDDATA pData; HWND hWndParent; POINT TmpPoint; RECT Rect; L_INT nTempint; L_INT cxClient; L_INT cyClient; L_INT nCount; L_BOOL bCurs = FALSE; LPDTNDLGDATA pDtnDlgData; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); cxClient= Rect.right - Rect.left; cyClient= Rect.bottom - Rect.top; TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient( GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &TmpPoint); if (PtInRect(&Rect, TmpPoint) && !pDtnDlgData->bOper) { nTempint = pDtnDlgData->aptCurve[pDtnDlgData->nIndex][TmpPoint.x].y; if(TmpPoint.y < nTempint + 30 && TmpPoint.y > nTempint - 30) { SetCursor(LoadCursor(NULL, IDC_CROSS)); } for(nCount = 0; nCount <= (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex]; nCount++) { SetRect(&Rect, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x - 5, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y - 30, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x + 5, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y + 30); if (PtInRect(&Rect, TmpPoint)) { bCurs = TRUE; break; } } if(bCurs) SetCursor(LoadCursor(NULL, IDC_SIZEALL)); if(pDtnDlgData->bChange) { if(!ChangeUserPoints(TmpPoint.x, TmpPoint.y, pDtnDlgData->nPoint[pDtnDlgData->nIndex], pDtnDlgData)) DeleteUserPoint(TmpPoint.x, TmpPoint.y, pDtnDlgData->nPoint[pDtnDlgData->nIndex], pDtnDlgData); GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); InvalidateRect(hWnd, NULL, FALSE); } UNLOCKCHILDDATA(hWndParent); return FALSE; } else { pDtnDlgData->bChange = FALSE; pDtnDlgData->bAdd = FALSE; } return FALSE; } static L_BOOL DtnDlg_OnLButtonDown (HWND hWnd, BOOL fDoubleClick, L_INT nX, L_INT nY, UINT keyFlags) { pCHILDDATA pData; HWND hWndParent; POINT TmpPoint; RECT Rect; L_INT nTempint; L_INT cxClient; L_INT cyClient; L_INT nCount; LPDTNDLGDATA pDtnDlgData ; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_ST_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_ST_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 0) { pDtnDlgData->nIndex = 0; pDtnDlgData->bOper = FALSE; if(pDtnDlgData->ChanData[pDtnDlgData->nIndex].bOper) pDtnDlgData->bOper = TRUE; Button_SetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK), !pDtnDlgData->bOper); ComboBox_Enable(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->bOper); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper); Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2 ) && pDtnDlgData->bOper); SetDlgItemInt(hWnd, IDC_DTN_FCTR_TXT, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, TRUE); InvalidateRect(hWnd, NULL, FALSE); return TRUE; } TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_ND_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_ND_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 1) { pDtnDlgData->nIndex = 1; pDtnDlgData->bOper = FALSE; if(pDtnDlgData->ChanData[pDtnDlgData->nIndex].bOper) pDtnDlgData->bOper = TRUE; Button_SetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK), !pDtnDlgData->bOper); ComboBox_Enable(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->bOper); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper); Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2 ) && pDtnDlgData->bOper); SetDlgItemInt(hWnd, IDC_DTN_FCTR_TXT, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, TRUE); InvalidateRect(hWnd, NULL, FALSE); return TRUE; } TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_TH_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_TH_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 2) { pDtnDlgData->nIndex = 2; pDtnDlgData->bOper = FALSE; if(pDtnDlgData->ChanData[pDtnDlgData->nIndex].bOper) pDtnDlgData->bOper = TRUE; Button_SetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK), !pDtnDlgData->bOper); ComboBox_Enable(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->bOper); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper); Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2 ) && pDtnDlgData->bOper); SetDlgItemInt(hWnd, IDC_DTN_FCTR_TXT, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, TRUE); InvalidateRect(hWnd, NULL, FALSE); return TRUE; } TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient(GetDlgItem(hWnd, IDC_DTN_FO_IMG), &TmpPoint); GetClientRect(GetDlgItem(hWnd, IDC_DTN_FO_IMG), &Rect); if (PtInRect(&Rect, TmpPoint) && pDtnDlgData->ColorNum >= 3) { pDtnDlgData->nIndex = 3; pDtnDlgData->bOper = FALSE; if(pDtnDlgData->ChanData[pDtnDlgData->nIndex].bOper) pDtnDlgData->bOper = TRUE; Button_SetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK), !pDtnDlgData->bOper); ComboBox_Enable(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->bOper); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper); Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2 ) && pDtnDlgData->bOper); SetDlgItemInt(hWnd, IDC_DTN_FCTR_TXT, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, TRUE); InvalidateRect(hWnd, NULL, FALSE); return TRUE; } GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); cxClient= Rect.right - Rect.left; cyClient= Rect.bottom - Rect.top; TmpPoint.x = nX; TmpPoint.y = nY; ClientToScreen(hWnd, &TmpPoint); ScreenToClient( GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &TmpPoint); if (PtInRect(&Rect, TmpPoint) && !pDtnDlgData->bOper) { nTempint = pDtnDlgData->aptCurve[pDtnDlgData->nIndex][TmpPoint.x].y; if(TmpPoint.y < nTempint + 30 && TmpPoint.y > nTempint - 30) { SetCursor(LoadCursor(NULL, IDC_SIZEALL)); for(nCount=0; nCount <= (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex];nCount++) { SetRect(&Rect, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x - 5, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y - 30, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x + 5, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y + 30); if (PtInRect(&Rect, TmpPoint) || TmpPoint.x < pDtnDlgData->UserPoint[pDtnDlgData->nIndex][0].x|| TmpPoint.x > pDtnDlgData->UserPoint[pDtnDlgData->nIndex] [pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] - 1].x) { pDtnDlgData->bChange = TRUE; pDtnDlgData->nPoint[pDtnDlgData->nIndex] = nCount; if(TmpPoint.x < pDtnDlgData->UserPoint[pDtnDlgData->nIndex][0].x) { pDtnDlgData->nPoint[pDtnDlgData->nIndex] = nCount; } if(TmpPoint.x > pDtnDlgData->UserPoint[pDtnDlgData->nIndex] [pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] - 1].x) pDtnDlgData->nPoint[pDtnDlgData->nIndex] = pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] - 1; if(!ChangeUserPoints(TmpPoint.x, TmpPoint.y, pDtnDlgData->nPoint[pDtnDlgData->nIndex], pDtnDlgData)) DeleteUserPoint(TmpPoint.x, TmpPoint.y, pDtnDlgData->nPoint[pDtnDlgData->nIndex], pDtnDlgData); GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); InvalidateRect(hWnd, NULL, FALSE); UNLOCKCHILDDATA(hWndParent); return TRUE; } } pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex]++; AddArrayPoint(TmpPoint.x, TmpPoint.y, pDtnDlgData); GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); InvalidateRect(hWnd, NULL, FALSE); UNLOCKCHILDDATA(hWndParent); return TRUE; } } return FALSE; } static L_BOOL DtnDlg_OnLButtonUp (HWND hWnd, L_INT nX, L_INT nY, UINT keyFlags) { LPDTNDLGDATA pDtnDlgData ; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); pDtnDlgData->bChange = FALSE; pDtnDlgData->bAdd = FALSE; if(pDtnDlgData->bChange || pDtnDlgData->bAdd) SetCursor(LoadCursor(NULL, IDC_SIZEALL)); return TRUE; } static L_BOOL DtnDlg_OnCommand(HWND hWnd, int nID, HWND hwndCtl, UINT codeNotify) { HWND hWndParent; pCHILDDATA pData; RECT Rect; L_INT nCount; LPDTNDLGDATA pDtnDlgData ; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); if ((codeNotify == CBN_SELCHANGE ) && (nID == IDC_DTN_OPR_COM)) { GetFunctinalTable(hWnd, FALSE, pDtnDlgData); InvalidateRect(hWnd, NULL, FALSE); Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2)); return FALSE; } if (nID == IDC_DTN_FCTR_TXT) { if(codeNotify == EN_CHANGE) { if ((pDtnDlgData->bOper) && (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2)) { nCount = GetDlgItemInt(hWnd, nID, NULL, TRUE); if(pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor == nCount) return FALSE; pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor = nCount; GetFunctinalTable(hWnd, FALSE, pDtnDlgData); InvalidateRect(hWnd, NULL, FALSE); } } return FALSE; } if ((codeNotify == CBN_SELCHANGE ) && (nID == IDC_DTN_CLR_COM)) { pDtnDlgData->ColorNum = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_DTN_CLR_COM)); pDtnDlgData->nIndex = pDtnDlgData->ColorNum; pDtnDlgData->bOper = pDtnDlgData->ChanData[pDtnDlgData->nIndex].bOper; Edit_Enable (GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), FALSE); Button_SetCheck (GetDlgItem(hWnd, IDC_DTN_USER_CHK), !pDtnDlgData->bOper); ComboBox_Enable (GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->bOper); SetDlgItemInt (hWnd, IDC_DTN_FCTR_TXT, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, TRUE); if (pDtnDlgData->bOper) { ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_DTN_OPR_COM), pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper); } SetDlgItemInt (hWnd, IDC_DTN_FCTR_TXT, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, TRUE); Edit_Enable (GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2 ) && pDtnDlgData->bOper); if(pDtnDlgData->bOper) GetFunctinalTable(hWnd, FALSE, pDtnDlgData); else { GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); } InvalidateRect(hWnd, NULL, FALSE); } switch (nID) { case IDC_DTN_USER_CHK: if(!Button_GetCheck(GetDlgItem(hWnd, IDC_DTN_USER_CHK))) { pDtnDlgData->ChanData[pDtnDlgData->nIndex].bOper = TRUE; ComboBox_Enable(GetDlgItem(hWnd, IDC_DTN_OPR_COM), TRUE); SetDlgItemInt (hWnd, IDC_DTN_FCTR_TXT, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, TRUE); if (pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper != 2) Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), TRUE); pDtnDlgData->bOper = TRUE; GetFunctinalTable(hWnd, FALSE, pDtnDlgData); } else { pDtnDlgData->ChanData[pDtnDlgData->nIndex].bOper = FALSE; ComboBox_Enable(GetDlgItem(hWnd, IDC_DTN_OPR_COM), FALSE); Edit_Enable(GetDlgItem(hWnd, IDC_DTN_FCTR_TXT), FALSE); pDtnDlgData->bOper = FALSE; GetLookTable(hWnd, pDtnDlgData); GetTable(hWnd); } InvalidateRect(hWnd, NULL, FALSE); break; case IDCANCEL: StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE; StatusProc.ProgressValue = 100; InvalidateRect(hWndParent, NULL, FALSE); EndDialog(hWnd, FALSE); break; case IDOK: ShowStatusWindow(FALSE); StatusProc.bStillWork = TRUE; InvalidateRect(hWndParent, NULL, FALSE); StatusProc.bInvalidate = TRUE; StatusProc.bEnd = TRUE; EndDialog(hWnd, TRUE); break; } UNLOCKCHILDDATA(hWndParent); return TRUE; } L_VOID InitPolygon(HWND hWnd, LPDTNDLGDATA pDtnDlgData) { L_INT nCount; RECT Rect; GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); for(nCount = 0; nCount <= 3; nCount++) { pDtnDlgData->UserPoint[nCount][0].x = 0; pDtnDlgData->UserPoint[nCount][0].y = (Rect.bottom - Rect.top); pDtnDlgData->UserPoint[nCount][1].x = (Rect.right - Rect.left); pDtnDlgData->UserPoint[nCount][1].y = 0; } } L_VOID GetLookTable(HWND hWnd, LPDTNDLGDATA pDtnDlgData) { RECT Rect; L_INT cxClient; L_INT cyClient; L_INT nCount; GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); cxClient= Rect.right - Rect.left; cyClient= Rect.bottom - Rect.top; L_GetUserLookUpTable(pDtnDlgData->pCurveTable, pDtnDlgData->uLUTLen + 1, pDtnDlgData->UserPoint[pDtnDlgData->nIndex], pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex], &pDtnDlgData->nPtCurveNo[pDtnDlgData->nIndex]); for(nCount = 0;nCount <= cxClient;nCount++) { pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nCount].x = min(cxClient, nCount); pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nCount].y = min(cyClient - 2, (L_INT)pDtnDlgData->pCurveTable[nCount]); } for(nCount = 0;nCount < pDtnDlgData->UserPoint[pDtnDlgData->nIndex][0].x; nCount++) { pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nCount].x = nCount; pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nCount].y = max(0, min (cyClient - 2, pDtnDlgData->UserPoint[pDtnDlgData->nIndex][0].y)); } for(nCount += pDtnDlgData->nPtCurveNo[pDtnDlgData->nIndex];nCount <= cxClient; nCount++) { pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nCount].x = nCount; pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nCount].y = max(0, min (cyClient - 2, pDtnDlgData->UserPoint[pDtnDlgData->nIndex] [pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] - 1].y)); } } L_VOID AddArrayPoint(L_INT nX, L_INT nY, LPDTNDLGDATA pDtnDlgData) { L_INT nCount; L_INT nShift; for(nCount = 0;nCount < (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex];nCount++) { if (nX < pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x) break; } for(nShift = pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] - 1;nShift >nCount;nShift--) { pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nShift].x = pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nShift-1].x; pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nShift].y = pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nShift-1].y; } pDtnDlgData->UserPoint [pDtnDlgData->nIndex][nCount].x = nX; pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y = nY; pDtnDlgData->nPoint[pDtnDlgData->nIndex] = nCount; pDtnDlgData->bChange= TRUE; pDtnDlgData->bAdd= FALSE; } L_BOOL ChangeUserPoints(L_INT nX, L_INT nY, L_INT Point, LPDTNDLGDATA pDtnDlgData) { if(Point == 0 || Point == (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] -1) { if(Point == (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] -1 && nX < pDtnDlgData->UserPoint[pDtnDlgData->nIndex] [pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] - 2].x + 5) return TRUE; if(Point == 0 && nX > pDtnDlgData->UserPoint[pDtnDlgData->nIndex][1].x - 5) return TRUE; pDtnDlgData->UserPoint[pDtnDlgData->nIndex][Point].x = nX; pDtnDlgData->UserPoint[pDtnDlgData->nIndex][Point].y = nY; return TRUE; } if(nX <= pDtnDlgData->UserPoint[pDtnDlgData->nIndex][Point-1].x || nX >= pDtnDlgData->UserPoint[pDtnDlgData->nIndex][Point+1].x) return FALSE; pDtnDlgData->UserPoint[pDtnDlgData->nIndex][Point].x = nX; pDtnDlgData->UserPoint[pDtnDlgData->nIndex][Point].y = nY; return TRUE; } L_VOID DeleteUserPoint(L_INT nX, L_INT nY, L_INT Point, LPDTNDLGDATA pDtnDlgData) { L_INT nCount; if (Point == 0 || Point == (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex]) return; for(nCount = Point; nCount < (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex]; nCount++) { pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x = pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount+1].x; pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y = pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount+1].y; } pDtnDlgData->bChange = FALSE; pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex]--; } L_VOID MakeGradient(HWND hWnd) { L_INT nCounter, nCounter1; L_UINT nRedFactor, nGreenFactor, nBlueFactor; L_UINT nRedValue, nGreenValue, nBlueValue; LPDTNDLGDATA pDtnDlgData; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); for (nCounter1 = 0; nCounter1 <= (L_INT)pDtnDlgData->ColorNum; nCounter1++) { nRedValue = GetRValue(pDtnDlgData->Color[nCounter1]); nGreenValue = GetGValue(pDtnDlgData->Color[nCounter1]); nBlueValue = GetBValue(pDtnDlgData->Color[nCounter1]); nRedFactor = ((255 - nRedValue) * 1000) / 255; nGreenFactor = ((255 - nGreenValue) * 1000) / 255; nBlueFactor = ((255 - nBlueValue) * 1000) / 255; for (nCounter = 0; nCounter < 256; nCounter++) { pDtnDlgData->pRGBArray[nCounter1][nCounter].rgbRed = nRedValue + ((nRedFactor * pDtnDlgData->uLut[nCounter1][nCounter]) / 1000); pDtnDlgData->pRGBArray[nCounter1][nCounter].rgbGreen = nGreenValue + ((nGreenFactor * pDtnDlgData->uLut[nCounter1][nCounter]) / 1000); pDtnDlgData->pRGBArray[nCounter1][nCounter].rgbBlue = nBlueValue + ((nBlueFactor * pDtnDlgData->uLut[nCounter1][nCounter]) / 1000); } } L_ApplyFilter (hWnd); } L_VOID GetTable(HWND hWnd) { RECT Rect; L_INT cxClient; L_INT cyClient; L_INT nCount; HWND hWndParent; pCHILDDATA pData; LPDTNDLGDATA pDtnDlgData ; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); cxClient= Rect.right - Rect.left; cyClient= Rect.bottom - Rect.top; for(nCount = 0; nCount < (L_INT)pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex]; nCount++) { pDtnDlgData->TablePoint[pDtnDlgData->nIndex][nCount].x = (pDtnDlgData->uLUTLen * pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].x)/cxClient; pDtnDlgData->TablePoint[pDtnDlgData->nIndex][nCount].y = pDtnDlgData->uLUTLen - (pDtnDlgData->uLUTLen* pDtnDlgData->UserPoint[pDtnDlgData->nIndex][nCount].y)/cyClient; } L_GetUserLookUpTable(pDtnDlgData->uLut[pDtnDlgData->nIndex], pDtnDlgData->uLUTLen + 1, pDtnDlgData->TablePoint[pDtnDlgData->nIndex], pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex], &pDtnDlgData->uUsrPntCnt[pDtnDlgData->nIndex]); for(nCount = 0;nCount < pDtnDlgData->TablePoint[pDtnDlgData->nIndex][0].x; nCount++) { pDtnDlgData->uLut[pDtnDlgData->nIndex][nCount] = (L_UCHAR)pDtnDlgData->TablePoint[pDtnDlgData->nIndex][0].y; } for(nCount += pDtnDlgData->uUsrPntCnt[pDtnDlgData->nIndex]; nCount <= (L_INT)pDtnDlgData->uLUTLen; nCount++) { pDtnDlgData->uLut[pDtnDlgData->nIndex][nCount] = max(0, min ((L_INT)pDtnDlgData->uLUTLen, pDtnDlgData->TablePoint[pDtnDlgData->nIndex] [pDtnDlgData->nUserPntCnt[pDtnDlgData->nIndex] - 1].y)); } pDtnDlgData->ColorNum = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_DTN_CLR_COM)); MakeGradient(hWnd); UNLOCKCHILDDATA(hWndParent); } L_VOID GetFunctinalTable(HWND hWnd, L_BOOL bInit, LPDTNDLGDATA pDtnDlgData) { L_INT nI; L_INT nPointno; RECT Rect; HWND hWndParent; pCHILDDATA pData; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); GetClientRect(GetDlgItem(hWnd, IDC_DTN_CRV_TXT), &Rect); pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper= ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_DTN_OPR_COM)); pDtnDlgData->uLut[pDtnDlgData->nIndex][0] = 0; pDtnDlgData->uLut[pDtnDlgData->nIndex][pDtnDlgData->uLUTLen] = pDtnDlgData->uLUTLen; pDtnDlgData->pCurveTable[0] = 0; pDtnDlgData->pCurveTable[Rect.right - Rect.left] = Rect.right - Rect.left; L_GetFunctionalLookupTable(pDtnDlgData->uLut[pDtnDlgData->nIndex], pDtnDlgData->uLUTLen + 1, 0, pDtnDlgData->uLUTLen, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper); L_GetFunctionalLookupTable(pDtnDlgData->pCurveTable, pDtnDlgData->uLUTLen + 1, 0, Rect.right - Rect.left, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nFactor, pDtnDlgData->ChanData[pDtnDlgData->nIndex].nOper); nPointno = Rect.right - Rect.left + 1; for(nI = 0; nI < nPointno; nI++) { pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nI].x = min(Rect.right- Rect.left - 1, nI); pDtnDlgData->aptCurve[pDtnDlgData->nIndex][nI].y = min((Rect.bottom- Rect.top) - 2, (Rect.bottom- Rect.top) - (L_INT)pDtnDlgData->pCurveTable[nI]); } if(!bInit) { MakeGradient(hWnd); } UNLOCKCHILDDATA(hWndParent); } static L_VOID L_ApplyFilter (HWND hWnd) { pCHILDDATA pData; L_INT nRet = 0; HWND hWndParent; LPDTNDLGDATA pDtnDlgData; BITMAPHANDLE TmpBitmap; pDtnDlgData = (LPDTNDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); if ( 100 != StatusProc.ProgressValue ) { StatusProc.bKillProgress = TRUE ; return ; } if (pDtnDlgData->BackUpGray.BitsPerPixel > 8) { L_FreeBitmap(&pData->LeadBitmap); L_CopyBitmap(&pData->LeadBitmap, &pDtnDlgData->BackUpGray, sizeof(BITMAPHANDLE)); } L_CopyBitmap(&TmpBitmap, &pDtnDlgData->BackUpGray, sizeof(BITMAPHANDLE)); nRet = L_GrayScaleToMultitone(&TmpBitmap, DT_MONOTONE + pDtnDlgData->ColorNum, DT_USERDEFINE, NULL, pDtnDlgData->pRGBArray, TRUE); if(nRet == SUCCESS) { L_FreeBitmap(&pData->LeadBitmap); L_CopyBitmap(&pData->LeadBitmap, &TmpBitmap, sizeof(BITMAPHANDLE)); InvalidateRect(hWndParent, NULL, FALSE); StatusProc.ProgressValue = 100; Progress_SetPos(StatusProc.ProgWnd , 0); if(StatusProc.bEnd) { StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE ; } } L_FreeBitmap(&TmpBitmap); }