Esempio n. 1
0
//		Sets the HMS readouts for the histo dialog based on the histogram control!
void CHistogramDlg::histo_set_HMSvalues()
{
	HWND hHisto;
	LPDWORD lpHisto;
	BOOL bInv;
	LONG lTotal;
	int iHisto;
	int i,j, start, end;
	int marks[HISTOMARKS];
	LONG sums[HISTOMARKS+1];
	double percents[HISTOMARKS+1];
	LONG sum;
	int add;
	char szDouble[30];
	HWND hDlg = GetSafeHwnd();

	lpHisto = get_histo(m_lpHistos, m_wChannel, &bInv, &iHisto);
	if (!lpHisto)
		return;
	lTotal = m_lTotals[iHisto];
	
	hHisto = ::GetDlgItem(hDlg, IDC_HISTOGRAM);
	
	// get the marks
	for (i=0;i<HISTOMARKS;i++)
	{
		marks[i] = Histo_GetMark(hHisto, i);
	}
	
	// get the three sums
	end = bInv ? 255:0;
	add = bInv ? -1:1;
	for (i=0;i<=HISTOMARKS;i++)
	{
		start = end;
		if (i >= HISTOMARKS)
			end = bInv ? 0:255;
		else
			end = bInv ? (255-marks[i]):marks[i];
		sum = 0L;
		for (j=start;j*add<end*add;j += add)
			sum += lpHisto[j];
		sums[i] = sum;
	}
	// scale if needed
	if (lTotal > 0x100000)
	{
		lTotal >>= 8L;
		for (i=0;i<=HISTOMARKS;i++)
			sums[i] >>= 8L;
	}
Esempio n. 2
0
//		Updates the display.
void CHistogramDlg::set_histo_channel()
{
	HWND hHisto, hTags;
	BOOL bInv, bMakeTotals;
	LPDWORD lpHisto;
	int i, j, iHisto;
	LONG sum;
	LONG lMaxEntry;
	LPDWORD lpdw;
	char szNum[40];
	HWND hDlg = GetSafeHwnd();
	
	bMakeTotals = (m_lpHistos[0] == NULL);
	lpHisto = get_histo(m_lpHistos, m_wChannel, &bInv, &iHisto);
	if (!lpHisto)
		return;
	
	// need to compute totals?
	if (bMakeTotals)
	{	
    	for (j=0;j<5;j++)
		{
			lpdw = m_lpHistos[j];
			sum = 0L;
			for (i=0;i<256;i++)
				sum += *lpdw++;
			m_lTotals[j] = sum;
		}
	}
	
	// setup the histo control
	lMaxEntry = compute_yscale(lpHisto);
	hHisto = ::GetDlgItem(hDlg, IDC_HISTOGRAM);
	Histo_Init(hHisto, lpHisto, lMaxEntry, HISTOMARKS, bInv ? HTS_FLIPX:0);
	// reset marks based on tag
	hTags = ::GetDlgItem(hDlg, IDC_TAGS);
	i = Tag_GetMark(hTags,0);
	Histo_SetMark(hHisto, 0, i, NO);
	i = Tag_GetMark(hTags,1);
	Histo_SetMark(hHisto, 1, i, NO);
	
	// setup the gradient
	set_gradient(IDC_HISTO_GRAD, m_wChannel);
	
	// setup readouts
	::SetDlgItemText(hDlg, IDC_HISTO_TOTAL, ltoa(m_lTotals[iHisto],szNum,10));
	::SetDlgItemText(hDlg, IDC_HISTO_POS, (LPSTR)"");
	::SetDlgItemText(hDlg, IDC_HISTO_VALUE, (LPSTR)"");
	histo_set_HMSvalues();
}
Esempio n. 3
0
//-----------------------------------------------------------------------------------------
// Get FACS data and histogram data
//-----------------------------------------------------------------------------------------
void ExecThread::getFACS()
{
//    LOG_MSG("get_nfacs");
    get_nfacs(&Global::nFACS_cells);
    if (!Global::FACS_data || Global::nFACS_cells*Global::nvars_used > Global::nFACS_dim) {
        if (Global::FACS_data) free(Global::FACS_data);
        Global::nFACS_dim = 3*Global::nFACS_cells*Global::nvars_used;   // 3* to avoid excessive malloc/free
        Global::FACS_data = (double *)malloc(Global::nFACS_dim*sizeof(double));
    }
//    LOG_MSG("get_facs");
    get_facs(Global::FACS_data);
    if (!Global::histo_data || Global::nhisto_bins*Global::nvars_used > Global::nhisto_dim) {
        if (Global::histo_data) free(Global::histo_data);
        if (Global::histo_data_log) free(Global::histo_data_log);
        Global::nhisto_dim = 6*Global::nhisto_bins*Global::nvars_used;   // 2*3 to avoid excessive malloc/free (only 3* used)
        Global::histo_data = (double *)malloc(Global::nhisto_dim*sizeof(double));
        Global::histo_data_log = (double *)malloc(Global::nhisto_dim*sizeof(double));
    }
//    LOG_MSG("get_histo");
    get_histo(Global::nhisto_bins, Global::histo_data, Global::histo_vmin, Global::histo_vmax,
              Global::histo_data_log, Global::histo_vmin_log, Global::histo_vmax_log);
//    LOG_MSG("did get_histo");
}
Esempio n. 4
0
//			Uses Mapping.Quarter_HSacrifice & Mapping.Quarter_SSacrifice
//			to set the highlights midtones and shaddows.
void CToneBalanceDlg::set_sacrifice(LPQUARTERSTRUCT lpData, WORD wChannel)
{
	LPMAP lpMap;
	LPDWORD lpHisto;
	BOOL bInv;
	LONG lSum, lSearch, lTotal;
	int hi, lo, i;
	
	// get the map & set its invert flags
	lpMap = tone_activate_channel( wChannel );
	lpHisto = get_histo(lpData->lpHistos, wChannel, &bInv);
	// determine initail values
	hi = 170;
	lo = 85;
	if (lpHisto)
	{
		// Find the total of all entries to scale
		lTotal = 0;
		for ( i=0; i<256; i++ )
			lTotal += lpHisto[i];

		// find the sacrafice
		lSearch = bInv ? m_nHSacrifice:m_nSSacrifice;
		lSearch = FMUL( lTotal, FGET( lSearch, 100 ) );
		lSum = -1;
		for ( i=0; i<255; i++ )
		{
			lSum += lpHisto[i];
			if ( lSum >= lSearch )
				break;
		}
		lo = i;
		
		// find the sacrafice
		lSearch = bInv ? m_nSSacrifice:m_nHSacrifice;
		lSearch = FMUL( lTotal, FGET( lSearch, 100 ) );
		lSum = -1;
		for ( i=255; i>0; i-- )
		{
			lSum += lpHisto[i];
			if ( lSum >= lSearch )
				break;
		}
		hi = i;
	}
	
	if (bInv)
	{
		hi = 255-hi;
		lo = 255-lo;
	}
	i = lo;
	lo = min(lo,hi);
	hi = max(i,hi);
	
	// setup the map
	if (wChannel == IDC_DO_ALL)
		ResetMapEx( lpMap, 3, NO, YES);
	else
		ResetMap( lpMap, 3, NO );
	lpMap->Pnt[0].x = lo;
	lpMap->Pnt[1].x = lo + (hi-lo)/2;
	lpMap->Pnt[2].x = hi;
}
Esempio n. 5
0
//************************************************************************
//		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);
}