#include "ImgPF.h" static L_BOOL PlaneCtlDialog_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT uCodeNotify); static L_BOOL PlaneCtlDialog_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam); static L_BOOL PlaneCtlDialog_OnPaint (HWND hWnd); static L_BOOL PlaneCtlDialog_OnClose (HWND hWnd); static L_VOID L_SetControlsValues (HWND hWnd, L_INT nIndex); static L_VOID GetPlanes (HWND hWnd); static L_VOID SetControlsNames (HWND hWnd, L_INT nIndex); L_BOOL CALLBACK PlaneCtlDlgProc (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { switch(uMessage) { HANDLE_MSG (hWnd, WM_INITDIALOG, PlaneCtlDialog_OnInitDialog); HANDLE_MSG (hWnd, WM_COMMAND, PlaneCtlDialog_OnCommand); HANDLE_MSG (hWnd, WM_PAINT, PlaneCtlDialog_OnPaint); HANDLE_MSG (hWnd, WM_CLOSE, PlaneCtlDialog_OnClose); case WM_USER_UPDATEVIEW: StatusProc.ProgressValue = 100; GetPlanes(hWnd); break; } return FALSE; } LRESULT CALLBACK WndPlanes (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { HWND hWndParent = GetParent(hWnd); LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWndParent, GWL_USERDATA); L_INT nIndex = GetWindowLong(hWnd, GWL_USERDATA); pCHILDDATA pData; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); switch(uMessage) { case WM_LBUTTONDOWN: { L_INT nOldIndex = pPlaneDlgData->nActivePlane; pPlaneDlgData->nActivePlane = nIndex; L_FreeBitmap(&pData->LeadBitmap); L_CopyBitmap(&pData->LeadBitmap, (nIndex == 0) ? &pPlaneDlgData->MergedBitmap : pPlaneDlgData->pArray[nIndex - 1], sizeof(BITMAPHANDLE)); InvalidateRect(GetDlgItem(GetParent(hWnd), IDC_PLANES_MASTER_TXT + nOldIndex), NULL, FALSE); InvalidateRect(hWnd, NULL, FALSE); InvalidateRect(hWndParent, NULL, FALSE); } break; case WM_PAINT: { RECT rcRect, rcFitRect; PAINTSTRUCT ps; HDC hDC; HPEN hPen, hOldPen; HPALETTE hPalette, hSavedPalette; pBITMAPHANDLE pPaintedBitmap; GetClientRect(hWnd, &rcRect); InflateRect(&rcRect, -1, -1); hDC = BeginPaint(hWnd, &ps); SelectBrush(hDC, GetStockBrush(HOLLOW_BRUSH)); hPen = CreatePen(0, 3, (pPlaneDlgData->nActivePlane == nIndex) ? RGB(0, 0, 255) : GetSysColor(COLOR_BTNFACE)); hOldPen = SelectPen(hDC, hPen); Rectangle(hDC, rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); SelectPen(hDC, hOldPen); DeletePen(hPen); InflateRect(&rcRect, -2, -2); pPaintedBitmap = (nIndex == 0) ? &pPlaneDlgData->MergedBitmap : pPlaneDlgData->pArray[nIndex - 1]; if (pPaintedBitmap == NULL) break; hPalette = L_CreatePaintPalette(hDC, pPaintedBitmap); hSavedPalette = SelectPalette(hDC, hPalette, TRUE); RealizePalette(hDC); FitImageToWindow(rcRect, pPaintedBitmap, &rcFitRect); OffsetRect(&rcFitRect, rcRect.left, rcRect.top); L_SetDisplayMode(DISPLAYMODE_BICUBIC, DISPLAYMODE_BICUBIC); L_PaintDC(hDC, pPaintedBitmap, NULL, NULL, &rcFitRect, NULL, SRCCOPY); hPalette = SelectPalette(hDC, hSavedPalette, TRUE); DeletePalette(hPalette); EndPaint(hWnd, &ps); } break; case WM_DESTROY: SetWindowLong(hWnd, GWL_WNDPROC, (long)pPlaneDlgData->OldPlanes); break; } return CallWindowProc(pPlaneDlgData->OldPlanes, hWnd, uMessage, wParam, lParam); } static L_BOOL PlaneCtlDialog_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam) { HWND hWndParent; pCHILDDATA pData; static L_BOOL bAppRun = FALSE; LPPLANESDLGDATA pPlaneDlgData; L_INT nI; pPlaneDlgData = (LPPLANESDLGDATA)GlobalAllocPtr(GHND, sizeof(PLANESDLGDATA)); if(!pPlaneDlgData) return FALSE; ZeroMemory(pPlaneDlgData, sizeof(PLANESDLGDATA)); SetWindowLong(hWnd, GWL_USERDATA, (long)pPlaneDlgData); MoveDialogToMiddle(hWnd); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); L_CopyBitmap(&pPlaneDlgData->OriginalBitmap, &pData->LeadBitmap, sizeof(BITMAPHANDLE)); L_CopyBitmap(&pPlaneDlgData->MergedBitmap, &pData->LeadBitmap, sizeof(BITMAPHANDLE)); pPlaneDlgData->nActivePlane = 0; pPlaneDlgData->nColorSpace = 1; for (nI = 0; nI < 4; nI++) pPlaneDlgData->pArray[nI] = (pBITMAPHANDLE)GlobalAllocPtr(GHND, sizeof(BITMAPHANDLE)); // Set the progress bar StatusProc.bProgress = TRUE; StatusProc.bInvalidate = FALSE; StatusProc.bKillProgress = FALSE; StatusProc.bEnd = FALSE; StatusProc.DlgWnd = hWnd; StatusProc.ProgressValue = 100; StatusProc.ProgWnd = GetDlgItem(hWnd, IDC_PLANES_PROG); Progress_SetRange(StatusProc.ProgWnd, 0, 100); Progress_SetPos (StatusProc.ProgWnd, 0); //GetPlanes(hWnd); /* if (pData->bImageChanged) { pData->bImageChanged = FALSE ; L_GetPlanes (hWnd, ComboBox_GetCurSel (GetDlgItem (hWnd, IDC_PLANES_SPACE_COM)), (pData->nSelBitmap >= 0) ? TRUE : FALSE) ; if (pData->nSelBitmap >= 0) { L_CopyBitmapHandle (&pData->LeadBitmap, &pData->bmMerged, sizeof (BITMAPHANDLE)) ; pData->nSelBitmap = -1; } L_UndoList_AddBitmap (hWndParent); pData->nNum++ ; } else { pData->hPlaneCtlWnd = hWnd ; pData->nSelBitmap = -1 ; if (!pData->bArrayAllocated) { pData->bmArray = malloc(sizeof(pBITMAPHANDLE) * 4); for (nCounter = 0; nCounter < 4; nCounter ++) pData->bmArray[nCounter] = malloc(sizeof(BITMAPHANDLE)); pData->bArrayAllocated = TRUE ; } wsprintf(pszChildTitle, "%s (%s)", pData->pszTitle, TEXT ("RGB Plane")) ; SetWindowText (hWndParent, pszChildTitle) ; L_CopyBitmapHandle (&pData->bmMerged, &pData->LeadBitmap, sizeof (BITMAPHANDLE)) ; GetClientRect (hWnd, &Rect) ; L_SetControlsValues(hWnd, 0) ; } if (!pData->nNum && !bAppRun) { pData->bArrayAllocated = FALSE ; UL_DelFirstNode (&pData->UndoList) ; L_UndoList_AddBitmap (hWndParent); pData->nNum++ ; bAppRun = TRUE ; GetClientRect (hWnd, &Rect) ; } pData->bInit_Add = TRUE ; ComboBox_ResetContent (GetDlgItem(hWnd, IDC_PLANES_SPACE_COM)) ; */ SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_MASTER_TXT), GWL_USERDATA, 0); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_MASTER_TXT), GWL_WNDPROC, (long)WndPlanes); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I1_TXT), GWL_USERDATA, 1); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I1_TXT), GWL_WNDPROC, (long)WndPlanes); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I2_TXT), GWL_USERDATA, 2); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I2_TXT), GWL_WNDPROC, (long)WndPlanes); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I3_TXT), GWL_USERDATA, 3); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I3_TXT), GWL_WNDPROC, (long)WndPlanes); pPlaneDlgData->OldPlanes = (WNDPROC) SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I4_TXT), GWL_WNDPROC, (long)WndPlanes); SetWindowLong(GetDlgItem(hWnd, IDC_PLANES_I4_TXT), GWL_USERDATA, 4); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("RGB")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("CMYK")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("HSV")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("HLS")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("CMY")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("YUV")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("XYZ")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("LAB")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("YCrCb")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TEXT("SCT")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), 0); GetPlanes(hWnd); UNLOCKCHILDDATA (hWnd) ; return (TRUE); } static L_BOOL PlaneCtlDialog_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT uCodeNotify) { HWND hWndParent; pCHILDDATA pData; // char pszWinText[20]; // char pszChildTitle[50]; // L_INT nRet; LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); // L_INT nI; // SetWindowLong(hWnd, GWL_USERDATA, (long)pPlaneDlgData); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); /* pData->nSelClrSpace = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM)); if ((uCodeNotify == CBN_SELCHANGE ) && (nID == IDC_PLANES_SPACE_COM)) { nRet = L_CopyBitmapHandle (&pData->LeadBitmap, &pData->bmMerged, sizeof (BITMAPHANDLE)); pData->nSelBitmap = -1; GetWindowText (GetDlgItem (hWnd, IDC_PLANES_SPACE_COM), pszWinText, 20) ; wsprintf(pszChildTitle, "%s (%s %s)", pData->pszTitle, pszWinText, TEXT (" Plane")) ; SetWindowText (hWndParent, pszChildTitle) ; L_SetControlsValues (hWnd, pData->nSelClrSpace); InvalidateRect(NULL, NULL, TRUE) ; } */ switch (nID) { case IDC_PLANES_SPACE_COM: if (uCodeNotify == CBN_SELCHANGE) { if (pPlaneDlgData->nColorSpace == ComboBox_GetCurSel(hWndCtl)) break; GetPlanes(hWnd); CallWindowProc(WndPlanes, GetDlgItem(hWnd, IDC_PLANES_MASTER_TXT + pPlaneDlgData->nActivePlane), WM_LBUTTONDOWN, 0, 0); } break; /* case IDC_MERGE_TXT: nRet = L_CopyBitmapHandle (&pData->LeadBitmap, &pData->bmMerged, sizeof (BITMAPHANDLE)) ; pData->nSelBitmap = -1 ; GetWindowText (GetDlgItem (hWnd, IDC_PLANES_SPACE_COM), pszWinText, 20) ; wsprintf(pszChildTitle, "%s (%s%s)", pData->pszTitle, pszWinText, TEXT (" Plane")) ; SetWindowText (hWndParent, pszChildTitle) ; InvalidateRect(NULL, NULL, TRUE) ; break ; case IDC_PLANES_I1_TXT: case IDC_PLANES_T1_TXT: nRet = L_CopyBitmapHandle (&pData->LeadBitmap, pData->bmArray[0], sizeof (BITMAPHANDLE)) ; pData->nSelBitmap = 0 ; GetWindowText (GetDlgItem (hWnd, IDC_PLANES_T1_TXT), pszWinText, 20) ; wsprintf(pszChildTitle, "%s (%s)", pData->pszTitle, pszWinText) ; SetWindowText (hWndParent, pszChildTitle) ; InvalidateRect(NULL, NULL, TRUE) ; break ; case IDC_PLANES_I2_TXT: case IDC_PLANES_T2_TXT: nRet = L_CopyBitmapHandle (&pData->LeadBitmap, pData->bmArray[1], sizeof (BITMAPHANDLE)) ; pData->nSelBitmap = 1 ; GetWindowText (GetDlgItem (hWnd, IDC_PLANES_T2_TXT), pszWinText, 20) ; wsprintf(pszChildTitle, "%s (%s)", pData->pszTitle, pszWinText) ; SetWindowText (hWndParent, pszChildTitle) ; InvalidateRect(NULL, NULL, TRUE) ; break ; case IDC_PLANES_I3_TXT: case IDC_PLANES_T3_TXT: nRet = L_CopyBitmapHandle (&pData->LeadBitmap, pData->bmArray[2], sizeof (BITMAPHANDLE)) ; pData->nSelBitmap = 2; GetWindowText (GetDlgItem (hWnd, IDC_PLANES_T3_TXT), pszWinText, 20) ; wsprintf(pszChildTitle, "%s (%s)", pData->pszTitle, pszWinText) ; SetWindowText (hWndParent, pszChildTitle) ; InvalidateRect(NULL, NULL, TRUE) ; break ; case IDC_PLANES_I4_TXT: case IDC_PLANES_T4_TXT: nRet = L_CopyBitmapHandle (&pData->LeadBitmap, pData->bmArray[3], sizeof (BITMAPHANDLE)) ; pData->nSelBitmap = 3 ; GetWindowText (GetDlgItem (hWnd, IDC_PLANES_T4_TXT), pszWinText, 20) ; wsprintf(pszChildTitle, "%s (%s)", pData->pszTitle, pszWinText) ; SetWindowText (hWndParent, pszChildTitle) ; InvalidateRect(NULL, NULL, TRUE) ; break ; */ case IDCANCEL: case IDOK: // pData->bPlaneCtl = FALSE ; // CheckMenuItem(GetMenu (hWndParent), IDM_OPTIONS_VIEW, MF_BYCOMMAND | MF_CHECKED) ; // SetWindowText (hWndParent, pData->pszTitle) ; // FARFREE (pData->bmArray) ; EnableWindow(GetDlgItem(hWnd, nID), TRUE); EndDialog(hWnd, FALSE); break; } UNLOCKCHILDDATA (hWndParent) ; return TRUE; } L_VOID DrawPlanesBorder (HWND hWnd, L_INT nI) { HDC hdc ; RECT rect ; hdc = GetDC (hWnd) ; GetClientRect (hWnd, &rect) ; SelectObject (hdc, CreatePen (PS_SOLID, 3, RGB (255, 0, 0))) ; switch (nI) { case -1: Rectangle (hdc, 13, 20, 55, 53); break; case 0: Rectangle (hdc, 13, 80, 55, 113); break; case 1: Rectangle (hdc, 13, 124, 55, 157); break; case 2: Rectangle (hdc, 13, 168, 55, 201); break; case 3: Rectangle (hdc, 13, 212, 55, 245); break; } ReleaseDC (hWnd, hdc) ; } static L_BOOL PlaneCtlDialog_OnPaint (HWND hWnd) { /* pCHILDDATA pData; RECT rcRect; HWND hWndParent ; HDC hDC; PAINTSTRUCT ps; HPALETTE hPalette, hSavedPalette; RECT rcImage; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA(hWndParent); DrawPlanesBorder(hWnd, pData->nSelBitmap) ; if (IsWindowEnabled(hWnd)) { // Mergerd bitmap... hDC = BeginPaint(GetDlgItem(hWnd, IDC_MERGE_TXT), &ps); GetClientRect(GetDlgItem(hWnd, IDC_MERGE_TXT), &rcImage); hPalette = L_CreatePaintPalette(hDC, &pData->bmMerged); hSavedPalette = SelectPalette(hDC, hPalette, TRUE); RealizePalette(hDC); FillRect(hDC, &rcImage, (HBRUSH) COLOR_WINDOW); FitImageToWindow(rcImage,&pData->bmMerged, &rcRect); L_PaintDC(hDC, &pData->bmMerged, NULL, NULL, &rcRect, NULL, SRCCOPY); hPalette = SelectPalette(hDC, hSavedPalette, TRUE); DeletePalette(hPalette); EndPaint(GetDlgItem(hWnd, IDC_MERGE_TXT), &ps); // Seperate bitmap 1... hDC = BeginPaint(GetDlgItem(hWnd, IDC_PLANES_I1_TXT), &ps); GetClientRect(GetDlgItem(hWnd, IDC_PLANES_I1_TXT), &rcImage); hPalette = L_CreatePaintPalette(hDC, pData->bmArray[0]); hSavedPalette = SelectPalette(hDC, hPalette, TRUE); RealizePalette(hDC); FillRect(hDC, &rcImage, (HBRUSH) COLOR_WINDOW); FitImageToWindow(rcImage,pData->bmArray[0], &rcRect); L_PaintDC(hDC, pData->bmArray[0], NULL, NULL, &rcRect, NULL, SRCCOPY); hPalette = SelectPalette(hDC, hSavedPalette, TRUE); DeletePalette(hPalette); EndPaint(GetDlgItem(hWnd, IDC_PLANES_I1_TXT), &ps); // Seperate bitmap 2... hDC = BeginPaint(GetDlgItem(hWnd, IDC_PLANES_I2_TXT), &ps); GetClientRect(GetDlgItem(hWnd, IDC_PLANES_I2_TXT), &rcImage); hPalette = L_CreatePaintPalette(hDC, pData->bmArray[1]); hSavedPalette = SelectPalette(hDC, hPalette, TRUE); RealizePalette(hDC); FillRect(hDC, &rcImage, (HBRUSH) COLOR_WINDOW); FitImageToWindow(rcImage,pData->bmArray[1], &rcRect); L_PaintDC(hDC, pData->bmArray[1], NULL, NULL, &rcRect, NULL, SRCCOPY); hPalette = SelectPalette(hDC, hSavedPalette, TRUE); DeletePalette(hPalette); EndPaint(GetDlgItem(hWnd, IDC_PLANES_I2_TXT), &ps); // Seperate bitmap 3... hDC = BeginPaint(GetDlgItem(hWnd, IDC_PLANES_I3_TXT), &ps); GetClientRect(GetDlgItem(hWnd, IDC_PLANES_I3_TXT), &rcImage); hPalette = L_CreatePaintPalette(hDC, pData->bmArray[2]); hSavedPalette = SelectPalette(hDC, hPalette, TRUE); RealizePalette(hDC); FillRect(hDC, &rcImage, (HBRUSH) COLOR_WINDOW); FitImageToWindow(rcImage,pData->bmArray[2], &rcRect); L_PaintDC(hDC, pData->bmArray[2], NULL, NULL, &rcRect, NULL, SRCCOPY); hPalette = SelectPalette(hDC, hSavedPalette, TRUE); DeletePalette(hPalette); EndPaint(GetDlgItem(hWnd, IDC_PLANES_I3_TXT), &ps); // Seperate bitmap 4... if (ComboBox_GetCurSel (GetDlgItem(hWnd, IDC_PLANES_SPACE_COM)) == 1) { hDC = BeginPaint(GetDlgItem(hWnd, IDC_PLANES_I4_TXT), &ps); GetClientRect(GetDlgItem(hWnd, IDC_PLANES_I4_TXT), &rcImage); hPalette = L_CreatePaintPalette(hDC, pData->bmArray[3]); hSavedPalette = SelectPalette(hDC, hPalette, TRUE); RealizePalette(hDC); FillRect(hDC, &rcImage, (HBRUSH) COLOR_WINDOW); FitImageToWindow(rcImage,pData->bmArray[3], &rcRect); L_PaintDC(hDC, pData->bmArray[3], NULL, NULL, &rcRect, NULL, SRCCOPY); hPalette = SelectPalette(hDC, hSavedPalette, TRUE); DeletePalette(hPalette); EndPaint(GetDlgItem(hWnd, IDC_PLANES_I4_TXT), &ps); } } UNLOCKCHILDDATA (hWndParent) ; */ return TRUE; } static L_BOOL PlaneCtlDialog_OnClose (HWND hWnd) { L_INT nI; LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); HWND hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pCHILDDATA pData = LOCKCHILDDATA(hWndParent); for (nI = 0; nI < 4; nI++) { if (pPlaneDlgData->pArray[nI]->Flags.Allocated) L_FreeBitmap(pPlaneDlgData->pArray[nI]); GlobalFreePtr(pPlaneDlgData->pArray[nI]); } L_FreeBitmap(&pPlaneDlgData->OriginalBitmap); L_FreeBitmap(&pData->LeadBitmap); L_CopyBitmap(&pData->LeadBitmap, &pPlaneDlgData->MergedBitmap, sizeof(BITMAPHANDLE)); L_FreeBitmap(&pPlaneDlgData->MergedBitmap); GlobalFree(pPlaneDlgData); EnableWindow(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM), TRUE); pData->hPlaneWnd = NULL; InvalidateRect(hWndParent, NULL, FALSE); /* pCHILDDATA pData ; HWND hWndParent ; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient, SendMessage); pData = LOCKCHILDDATA(hWndParent); pData->bPlaneCtl = FALSE ; if (pData->nSelBitmap >= 0) { L_CopyBitmapHandle (&pData->LeadBitmap, &pData->bmMerged, sizeof (BITMAPHANDLE)) ; pData->nSelBitmap = -1 ; } if (pData->bArrayAllocated) { FARFREE (pData->bmArray[0]) ; FARFREE (pData->bmArray[1]) ; FARFREE (pData->bmArray[2]) ; FARFREE (pData->bmArray[3]) ; pData->bArrayAllocated = FALSE ; } CheckMenuItem(GetMenu (hWndParent), IDM_OPTIONS_VIEW, MF_BYCOMMAND | MF_UNCHECKED) ; SendMessage (hWnd, IDCANCEL, 0, 0); InvalidateRect (hWndParent, NULL , TRUE) ;*/ return TRUE; } L_VOID SetControlsNames(HWND hWnd, L_INT nIndex) { L_TCHAR pLabelText1[20] ; L_TCHAR pLabelText2[20] ; L_TCHAR pLabelText3[20] ; L_TCHAR pLabelText4[20] ; RECT rect ; RECT rcRect; LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); // Prepair the labels text... switch (nIndex) { case 0: lstrcpy(pLabelText1, TEXT("Blue Plane")); lstrcpy(pLabelText2, TEXT("Green Plane")); lstrcpy(pLabelText3, TEXT("Red Plane")); break; case 1: lstrcpy(pLabelText1, TEXT("Cyan Plane")); lstrcpy(pLabelText2, TEXT("Magenta Plane")); lstrcpy(pLabelText3, TEXT("Yellow Plane")); lstrcpy(pLabelText4, TEXT("Black Plane")); break; case 2: lstrcpy(pLabelText1, TEXT("Hue Plane")); lstrcpy(pLabelText2, TEXT("Saturation Plane")); lstrcpy(pLabelText3, TEXT("Value Plane")); break; case 3: lstrcpy(pLabelText1, TEXT("Hue Plane")); lstrcpy(pLabelText2, TEXT("Lightness Plane")); lstrcpy(pLabelText3, TEXT("Saturation Plane")); break; case 4: lstrcpy(pLabelText1, TEXT("Cyan Plane")); lstrcpy(pLabelText2, TEXT("Magenta Plane")); lstrcpy(pLabelText3, TEXT("Yellow Plane")); break; case 5: lstrcpy(pLabelText1, TEXT("Y Plane")); lstrcpy(pLabelText2, TEXT("U Plane")); lstrcpy(pLabelText3, TEXT("V Plane")); break; case 6: lstrcpy(pLabelText1, TEXT("X Plane")); lstrcpy(pLabelText2, TEXT("Y Plane")); lstrcpy(pLabelText3, TEXT("Z Plane")); break; case 7: lstrcpy(pLabelText1, TEXT("L Plane")); lstrcpy(pLabelText2, TEXT("A Plane")); lstrcpy(pLabelText3, TEXT("B Plane")); break; case 8: lstrcpy(pLabelText1, TEXT("Y Plane")); lstrcpy(pLabelText2, TEXT("Cr Plane")); lstrcpy(pLabelText3, TEXT("Cb Plane")); break; case 9: lstrcpy(pLabelText1, TEXT("L Plane")); lstrcpy(pLabelText2, TEXT("T Plane")); lstrcpy(pLabelText3, TEXT("P Plane")); break; } // Set the labels text... SetDlgItemText (hWnd, IDC_PLANES_T1_TXT, pLabelText1); SetDlgItemText (hWnd, IDC_PLANES_T2_TXT, pLabelText2); SetDlgItemText (hWnd, IDC_PLANES_T3_TXT, pLabelText3); SetDlgItemText (hWnd, IDC_PLANES_T4_TXT, pLabelText4); GetClientRect(hWnd, &rect) ; if (nIndex == 1) { if (pPlaneDlgData->nColorSpace == 1) return; pPlaneDlgData->nColorSpace = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM)); ShowWindow(GetDlgItem(hWnd, IDC_PLANES_I4_TXT), SW_SHOW); ShowWindow(GetDlgItem(hWnd, IDC_PLANES_T4_TXT), SW_SHOW); GetWindowRect(hWnd, &rcRect); MoveWindow(hWnd, rcRect.left, rcRect.top, RECTWIDTH(&rcRect), RECTHEIGHT(&rcRect) + 40, TRUE) ; } else { if (pPlaneDlgData->nColorSpace != 1) return; pPlaneDlgData->nColorSpace = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM)); ShowWindow(GetDlgItem(hWnd, IDC_PLANES_I4_TXT), SW_HIDE); ShowWindow(GetDlgItem(hWnd, IDC_PLANES_T4_TXT), SW_HIDE); GetWindowRect(hWnd, &rcRect); MoveWindow(hWnd, rcRect.left, rcRect.top, RECTWIDTH(&rcRect), RECTHEIGHT(&rcRect) - 40, TRUE) ; } GetClientRect(hWnd, &rcRect); MoveWindow(GetDlgItem(hWnd, IDC_PLANES_PROG), rcRect.left + 6, rcRect.bottom - 20, RECTWIDTH(&rcRect) - 12, 15, TRUE) ; MoveWindow(GetDlgItem(hWnd, IDC_CLR_SPR_FRAME), rcRect.left + 6, 62, RECTWIDTH(&rcRect) - 12, RECTHEIGHT(&rcRect) - 85, TRUE) ; } L_VOID L_GetPlanes (HWND hWnd, L_INT nIndex, L_BOOL bMerge) { /* pCHILDDATA pData ; HWND hWndParent ; L_INT nRet = 0; L_INT nCounter ; if ( 100 != StatusProc.ProgressValue ) { StatusProc.bKillProgress = TRUE ; return ; } hWndParent = FORWARD_WM_MDIGETACTIVE (hWndClient, SendMessage); pData = LOCKCHILDDATA (hWndParent); // Prepair the bitmaps value... if (nIndex >= 0) { if (bMerge) { L_FreeBitmap(&pData->bmMerged) ; nRet = L_ColorMergeBitmap (&pData->bmMerged, pData->bmArray, sizeof(BITMAPHANDLE), nIndex) ; } else { for (nCounter = 0 ;nCounter < 4 ; nCounter++) L_FreeBitmap(pData->bmArray[nCounter]) ; nRet = L_ColorSeparateBitmap (&pData->bmMerged, pData->bmArray, sizeof(BITMAPHANDLE), nIndex) ; } if(nRet == SUCCESS) { StatusProc.ProgressValue = 100; Progress_SetPos(StatusProc.ProgWnd , 0); if(StatusProc.bEnd) { StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE; } } } InvalidateRect(hWnd, NULL, FALSE); UNLOCKCHILDDATA (hWndParent) ;*/ } /* if (pData->nNum) { // L_SaveBitmap (TEXT ("c:\\InitSave.jpg"), &pData->LeadBitmap, FILE_JPEG, pData->LeadBitmap.BitsPerPixel, // FILE_EXIF_JPEG, NULL) ; // MessageBox (NULL, "Saved", NULL, 0) ; L_UndoList_AddBitmap (hWndParent); } pData->nNum++ ; */ L_VOID GetPlanes(HWND hWnd) { HWND hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); pCHILDDATA pData = LOCKCHILDDATA(hWndParent); L_INT nIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM)); L_INT nI; L_INT nRet; if ( 100 != StatusProc.ProgressValue ) { StatusProc.bKillProgress = TRUE ; return ; } for (nI = 0; nI < 4; nI++) { if (pPlaneDlgData->pArray[nI]->Flags.Allocated) L_FreeBitmap(pPlaneDlgData->pArray[nI]); } SetControlsNames(hWnd, nIndex); nRet = L_ColorSeparateBitmap(&pPlaneDlgData->MergedBitmap, pPlaneDlgData->pArray, sizeof(BITMAPHANDLE), nIndex); if(nRet == SUCCESS) { StatusProc.ProgressValue = 100; Progress_SetPos(StatusProc.ProgWnd , 0); if(StatusProc.bEnd) { StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE; } } if (nIndex != 1) pPlaneDlgData->nActivePlane = min(3, pPlaneDlgData->nActivePlane); for (nI = 0; nI < 5; nI++) InvalidateRect(GetDlgItem(hWnd, IDC_PLANES_MASTER_TXT + nI), NULL, FALSE); } L_VOID SetPlanes(HWND hWnd) { HWND hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); pCHILDDATA pData = LOCKCHILDDATA(hWndParent); L_INT nIndex = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_PLANES_SPACE_COM)); L_INT nRet; if ( 100 != StatusProc.ProgressValue ) { StatusProc.bKillProgress = TRUE; return; } if (pPlaneDlgData->MergedBitmap.Flags.Allocated) L_FreeBitmap(&pPlaneDlgData->MergedBitmap); SetControlsNames(hWnd, nIndex); nRet = L_ColorMergeBitmap(&pPlaneDlgData->MergedBitmap, pPlaneDlgData->pArray, sizeof(BITMAPHANDLE), nIndex); if(nRet == SUCCESS) { InvalidateRect(GetDlgItem(hWnd, IDC_PLANES_MASTER_TXT), NULL, FALSE); StatusProc.ProgressValue = 100; Progress_SetPos(StatusProc.ProgWnd , 0); if(StatusProc.bEnd) { StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE; } } } L_VOID UpdatePlanes(HWND hWnd) { HWND hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); pCHILDDATA pData = LOCKCHILDDATA(hWndParent); if (pPlaneDlgData->nActivePlane == 0) { L_FreeBitmap(&pPlaneDlgData->MergedBitmap); L_CopyBitmap(&pPlaneDlgData->MergedBitmap, &pData->LeadBitmap, sizeof(BITMAPHANDLE)); GetPlanes(hWnd); } else { L_FreeBitmap(pPlaneDlgData->pArray[pPlaneDlgData->nActivePlane - 1]); L_CopyBitmap(pPlaneDlgData->pArray[pPlaneDlgData->nActivePlane - 1], &pData->LeadBitmap, sizeof(BITMAPHANDLE)); SetPlanes(hWnd); } } L_VOID L_PlaneUndoList_AddBitmap(HWND hWnd) { HWND hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); pCHILDDATA pData = LOCKCHILDDATA(hWndParent); BITMAPHANDLE Temp; UpdatePlanes(hWnd); L_CopyBitmapHandle(&Temp, &pData->LeadBitmap, sizeof(BITMAPHANDLE)); L_CopyBitmapHandle(&pData->LeadBitmap, &pPlaneDlgData->MergedBitmap, sizeof(BITMAPHANDLE)); L_UndoList_AddBitmap(hWndParent); L_CopyBitmapHandle(&pData->LeadBitmap, &Temp, sizeof(BITMAPHANDLE)); } L_VOID L_PlaneUndoList_Undo (HWND hWnd) { HWND hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); LPPLANESDLGDATA pPlaneDlgData = (LPPLANESDLGDATA)GetWindowLong(hWnd, GWL_USERDATA); pCHILDDATA pData = LOCKCHILDDATA(hWndParent); L_UndoList_Undo (hWndParent); MemorizeBitmap(hWndParent); L_FreeBitmap(&pPlaneDlgData->MergedBitmap); L_CopyBitmap(&pPlaneDlgData->MergedBitmap, &pData->LeadBitmap, sizeof(BITMAPHANDLE)); if (pPlaneDlgData->nActivePlane != 0) { L_FreeBitmap(&pData->LeadBitmap); L_CopyBitmap(&pData->LeadBitmap, pPlaneDlgData->pArray[pPlaneDlgData->nActivePlane - 1], sizeof(BITMAPHANDLE)); } GetPlanes(hWnd); } L_VOID L_PlaneUndoList_Redo (HWND hWnd) { }