BOOL CHistogramDlg::OnInitDialog() { HWND hActiveWnd; HWND hTags; FRMDATATYPE type; LPIMAGE lpImage = NULL; int icons[HISTOMARKS]; HWND hDlg = GetSafeHwnd(); lpImage = GetImage(); RightPopup( hDlg ); // set channels combo type = FrameType(ImgGetBaseEditFrame(lpImage)); m_wChannel = IDC_DO_ALL; m_MapValues.wChannel = m_wChannel; ChannelsCombo_Setup(IDC_CHANNELS, type); //This NEEDS to be fixed!!! // setup tags hTags = ::GetDlgItem(hDlg, IDC_TAGS); icons[0] = IDC_HISTOTAG1; icons[1] = IDC_HISTOTAG2; Tag_Init(hTags, HISTOMARKS, 255, &icons[0]); Tag_SetMark(hTags, 0, 85, NO); Tag_SetMark(hTags, 1, 170, NO); m_lpHistos[0] = NULL; // setup the actual histogram and controls set_histo_channel(); return CPPMapExDlg::OnInitDialog(); }
// Coordinates the tag control and the histo control for the // histogram dialog. // Updates readouts for H,M&S void CHistogramDlg::histo_change_mark(int nMark, int val) { HWND hHisto, hTag; int i; int Marks[HISTOMARKS]; HWND hDlg = GetSafeHwnd(); hHisto = ::GetDlgItem(hDlg, IDC_HISTOGRAM); // get the marks for (i=0;i<HISTOMARKS;i++) Marks[i] = Histo_GetMark(hHisto, i); // set value and adjust others if (nMark == 0) { Marks[0] = val; if (Marks[1] < Marks[0]) Marks[1] = Marks[0]; } else if (nMark == 1) { Marks[1] = val; if (Marks[1] < Marks[0]) Marks[0] = Marks[1]; } // update anything that needs it hTag = ::GetDlgItem(hDlg, IDC_TAGS); for (i=0;i<HISTOMARKS;i++) { if (Marks[i] != Histo_GetMark(hHisto,i)) Histo_SetMark(hHisto,i, Marks[i], NO); if (Marks[i] != Tag_GetMark(hTag,i)) Tag_SetMark(hTag,i, Marks[i], NO); } // set HMS readouts histo_set_HMSvalues(); }
//************************************************************************ // set_quarter_channel // DESCRIPTION: // Makes the given channel the current channel. // Updates the display. //************************************************************************ VOID CToneBalanceDlg::set_quarter_channel(WORD wChannel) //************************************************************************ { LPDWORD lpHisto; HWND hControl; BOOL bInv; LONG lMaxEntry; int icons[3]; HWND hDlg = GetSafeHwnd(); m_lpData->lpMap = tone_activate_channel( wChannel ); lpHisto = get_histo(m_lpData->lpHistos, wChannel, &bInv); // setup the histo control lMaxEntry = compute_yscale(lpHisto); hControl = ::GetDlgItem(hDlg, IDC_HISTOGRAM); Histo_Init(hControl, lpHisto, lMaxEntry, 3, bInv ? HTS_FLIPX:0); m_lpData->iShadow = m_lpData->lpMap->Pnt[0].x; m_lpData->iMidtone = m_lpData->lpMap->Pnt[1].x; m_lpData->iHighlight = m_lpData->lpMap->Pnt[2].x; if (!(m_lpData->iHighlight - m_lpData->iShadow)) m_lpData->MidtonePer = 0; else m_lpData->MidtonePer = (m_lpData->iMidtone - m_lpData->iShadow)*255/ (m_lpData->iHighlight - m_lpData->iShadow); Histo_SetMark(hControl, 0, m_lpData->lpMap->Pnt[0].x, NO); Histo_SetMark(hControl, 1, m_lpData->lpMap->Pnt[1].x, NO); Histo_SetMark(hControl, 2, m_lpData->lpMap->Pnt[2].x, NO); // some people seem to have an update problem here ::InvalidateRect (hControl,NULL,FALSE); // setup tags hControl = ::GetDlgItem(hDlg, IDC_TAGS); icons[0] = IDC_QUART1; icons[1] = IDC_QUART2; icons[2] = IDC_QUART3; Tag_Init(hControl, 3, 255, &icons[0]); Tag_SetMark(hControl, 0, m_lpData->lpMap->Pnt[0].x, NO); Tag_SetMark(hControl, 1, m_lpData->lpMap->Pnt[1].x, NO); Tag_SetMark(hControl, 2, m_lpData->lpMap->Pnt[2].x, NO); // some people seem to have an update problem here ::InvalidateRect (hControl,NULL,FALSE); set_gradient(IDC_HISTO_GRAD, wChannel); // spins InitDlgItemSpin(hDlg, IDC_QUART1_VALUE, TO_DISPLAY(m_lpData->lpMap->Pnt[0].x), NO, 0, MAX_SPIN); InitDlgItemSpin(hDlg, IDC_QUART3_VALUE, TO_DISPLAY(m_lpData->lpMap->Pnt[2].x), NO, 0, MAX_SPIN); if (m_bUseMidPer) InitDlgItemSpin(hDlg, IDC_QUART2_VALUE, m_lpData->MidtonePer*100L/255, NO, 0, MAX_SPIN ); else InitDlgItemSpin(hDlg, IDC_QUART2_VALUE, TO_DISPLAY(m_lpData->lpMap->Pnt[1].x), NO, 0, MAX_SPIN ); InitDlgItemSpin(hDlg, IDC_MINHIGHLIGHT, TO_DISPLAY(m_lpData->lpMap->Pnt[2].y), NO, 0, MAX_SPIN); InitDlgItemSpin(hDlg, IDC_MAXSHADOW, TO_DISPLAY(m_lpData->lpMap->Pnt[0].y), NO, 0, MAX_SPIN); }
//************************************************************************ // change_mark // PARAMETERS: // int nMark- which mark (0 for highlights etc) // int val- New value. // int inval- the 'readout' value of the given mark (INT_MAX for none) // Currently used only for midtone // DESCRIPTION: // Sets the mark, updates other marks to keep them valid. // Sets and redraws all appropriate controls. // Updates the map. //************************************************************************ void CToneBalanceDlg::change_mark(LPQUARTERSTRUCT lpData, int nMark, int val, int inval) //************************************************************************ { HWND hHisto, hTag; int i; BOOL Bool; int Marks[3]; HWND hDlg = GetSafeHwnd(); // set value and adjust others Marks[0] = lpData->iShadow; Marks[2] = lpData->iHighlight; if (m_bUseMidPer) Marks[1] = Marks[0] + (LONG)lpData->MidtonePer*(Marks[2]-Marks[0])/255; else Marks[1] = lpData->iMidtone; if (nMark == 0) { Marks[0] = lpData->iShadow = val; if (Marks[2] < Marks[0]) Marks[2] = Marks[0]; if (m_bUseMidPer) Marks[1] = Marks[0] + (LONG)lpData->MidtonePer*(Marks[2]-Marks[0])/255; else if (Marks[1] < Marks[0]) Marks[1] = Marks[0]; } else if (nMark == 2) { Marks[2] = lpData->iHighlight = val; if (Marks[0] > Marks[2]) Marks[0] = Marks[2]; if (m_bUseMidPer) Marks[1] = Marks[0] + (LONG)lpData->MidtonePer*(Marks[2]-Marks[0])/255; else if (Marks[1] > Marks[2]) Marks[1] = Marks[2]; } else if (nMark == 1) { Marks[1] = lpData->iMidtone = Bound(val, Marks[0], Marks[2]); if (Marks[2]-Marks[0]) lpData->MidtonePer = (lpData->iMidtone - Marks[0])*255L/(Marks[2]-Marks[0]); } else return; // update anything that needs it // spins i = GetDlgItemSpin(hDlg, IDC_QUART1_VALUE, &Bool, NO); i = FROM_DISPLAY(i); if (!Bool || i != Marks[0]) InitDlgItemSpin(hDlg, IDC_QUART1_VALUE, TO_DISPLAY(Marks[0]), NO, 0, MAX_SPIN ); if (inval != INT_MAX && nMark==1) { } else { // update percent if (m_bUseMidPer) { i = GetDlgItemSpin(hDlg, IDC_QUART2_VALUE, &Bool, NO); if (!Bool || (i*255L/100) != lpData->MidtonePer) InitDlgItemSpin(hDlg, IDC_QUART2_VALUE, lpData->MidtonePer*100L/255, NO, 0, MAX_SPIN ); } else { i = GetDlgItemSpin(hDlg, IDC_QUART2_VALUE, &Bool, NO); i = FROM_DISPLAY(i); if (!Bool || i != Marks[1]) InitDlgItemSpin(hDlg, IDC_QUART2_VALUE, TO_DISPLAY(Marks[1]), NO, 0, MAX_SPIN ); } } i = GetDlgItemSpin(hDlg, IDC_QUART3_VALUE, &Bool, NO); i = FROM_DISPLAY(i); if (!Bool || i != Marks[2]) InitDlgItemSpin(hDlg, IDC_QUART3_VALUE, TO_DISPLAY(Marks[2]), NO, 0, MAX_SPIN ); // histogram hHisto = ::GetDlgItem(hDlg, IDC_HISTOGRAM); hTag = ::GetDlgItem(hDlg, IDC_TAGS); for (i=0;i<3;i++) { if (Marks[i] != Histo_GetMark(hHisto,i)) Histo_SetMark(hHisto,i, Marks[i], NO); if (Marks[i] != Tag_GetMark(hTag,i)) Tag_SetMark(hTag,i, Marks[i], NO); } lpData->lpMap->Pnt[0].x = Marks[0]; lpData->lpMap->Pnt[1].x = Marks[1]; lpData->lpMap->Pnt[2].x = Marks[2]; }