Esempio n. 1
0
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink,
                      int n, const int *dx) {
	Std(font);
	font.Bold();
	while(n > 30000) {
		DrawTextOp(x, y, angle, text, font, ink, 30000, dx);
		if(dx)
			for(int i = 0; i < 30000; i++)
				x += *dx++;
		else
			x += GetTextSize(text, font, 30000).cx;
		n -= 30000;
		text += 30000;
	}
	GuiLock __;
	COLORREF cr = GetColor(ink);
	if(cr != lastTextColor) {
		LLOG("Setting text color: " << ink);
		::SetTextColor(handle, lastTextColor = cr);
	}
	HGDIOBJ orgfont = ::SelectObject(handle, GetWin32Font(font, angle));
	int ascent = font.Info().GetAscent();
	if(angle) {
		double sina, cosa;
		Draw::SinCos(angle, sina, cosa);
		Size offset;
		::ExtTextOutW(handle, x + fround(ascent * sina), y + fround(ascent * cosa), 0, NULL, (const WCHAR *)text, n, dx);
	}
	else
		::ExtTextOutW(handle, x, y + ascent, 0, NULL, (const WCHAR *)text,
		              n, dx);
	::SelectObject(handle, orgfont);
}
Esempio n. 2
0
//=============================================================================
//
// LoadStdImage()
//
// Purpose:     The LoadStdImage() Loads the image for the button.  This 
//				function (or LoadStdStyle()) must be called at a minimum.  
//				Automatically generates the other standard states.
//
// Parameters:  
//		[IN]	id
//				resource id, one of the resources already imported with the 
//				resource editor, usually begins with IDR_  
//
//		[IN]	pType
//				pointer to string describing the resource type
//				
// Returns:     BOOL
//				Non zero if successful, otherwise zero
//
//=============================================================================
BOOL StyleButton::LoadStdImage(UINT id, LPCTSTR pType)
{
	CRect rect; GetClientRect(rect);

	Stack Std(rect);
	Std.AddImage(CPoint(0,0), id, pType);
	m_StdStyle.AddStack(Std);

	Stack Press(rect);
	Press.AddImage(CPoint(1,1), id, pType);
	m_StdPStyle.AddStack(Press);

	Stack Hot(rect);
	Hot.AddImage(CPoint(0,0), id, pType, FALSE, LIGHTEN);
	m_StdHStyle.AddStack(Hot);

	Stack Gray(rect);
	Gray.AddImage(CPoint(0,0), id, pType, FALSE, GRAYSCALE);
	m_StdGStyle.AddStack(Gray);

	// create background
	Stack Back(rect);
	Back.FillSolid(CLEAR);
	m_Background.AddStack(Back);

	return TRUE;
}
Esempio n. 3
0
void TrainingSet::Concatenation(Mat & KEY, Point2d* VALUE, float* HighMean, int & count)
{

	for (int row = 0; row < m_PatchNo_row; row++)
	{
		for (int col = 0; col < m_PatchNo_col; col++)
		{

			Mat output;
			int MatSize=61;
			Vectorize(row, col, output,MatSize);
			float x = MatMean(output);
			float mean = Std(output, x);
			//output = output / mean;
			for (int n = 0; n < MatSize; n++)
			{
				KEY.at<float>(count, n) = output.at<float>(0, n)/mean;
			}
			HighMean[count] = mean;
			VALUE[count] = Point2d(row, col);
			count++;

			//Mat dsttemp = KEY.row(count);             //MΪĿµÄ¾ØÕó n*m
			//output.copyTo(dsttemp);
			//float y = KEY.at<float>(0, 1);
			/*if (row == 42 && col == 193 && count == 466609)
			{
			int errpr = 0;
			Mat a = m_highResPatches->GetPatch(row + 1, col + 1) / mean;
			}*/
			/*Mat a = m_highResPatches->GetPatch(row + 1, col + 1) / mean;
			if (row==310&&col==440)
			{
			int errpr = 0;
			}
			Mat b(1, 25, CV_32FC3);
			b = VALUE(Rect(0, count, 25, 1));*/
			/*int count = 0;
			for (int row = 0; row < 5; row++)
			{
			for (int col = 0; col < 5; col++)
			{
			for (int n = 0; n < 3; n++)
			{
			b.at<Vec3f>(0, count)[n] = a.at<Vec3f>(row, col)[n];
			}
			count++;
			}
			}*/
			//VALUE.push_back(m_highResPatches->GetPatch(row + 1, col + 1) / mean);
			//VALUE(Rect(count,0,1,25))=b;
			/*if (count == 466609)
			{
			int n = 0;
			}*/
		}
	}
}
Esempio n. 4
0
//========================================================================//
//Calculate the Pearson Coefficient of the two input vectors
//
//========================================================================//
double PearsonCoefficient(vector<double> x, vector<double> y)
{
	double coe=0.0;
	int N=x.size();
	
	double meanx=MeanVal(x);
	double meany=MeanVal(y);
	double stdx=Std(x);
	double stdy=Std(y);
	for(int i=0; i<N; i++)
	{
		coe += ((x[i]-meanx)/stdx)*((y[i]-meany)/stdy);
	}
	coe /= N;
	
	
	return coe;
}
Esempio n. 5
0
//=============================================================================
//
// LoadAltImage()
//
// Purpose:     The LoadAltImage() Loads the alternate image for the button.  
//				This function call is optional
//				Automatically generates the other alternate states.
//
// Parameters:  
//		[IN]	id
//				resource id, one of the resources already imported with the 
//				resource editor, usually begins with IDR_  
//
//		[IN]	pType
//				pointer to string describing the resource type
//				
// Returns:     BOOL
//				Non zero if successful, otherwise zero
//
//=============================================================================
BOOL StyleButton::LoadAltImage(UINT id, LPCTSTR pType)
{
	CRect rect; GetClientRect(rect);

	Stack Std(rect);
	Std.AddImage(CPoint(0,0), id, pType);
	m_AltStyle.AddStack(Std);

	Stack Press(rect);
	Press.AddImage(CPoint(1,1), id, pType);
	m_AltPStyle.AddStack(Press);

	Stack Hot(rect);
	Hot.AddImage(CPoint(0,0), id, pType, FALSE, LIGHTEN);
	m_AltHStyle.AddStack(Hot);

	m_bHaveAltStyle = TRUE;

	return TRUE;
}
Esempio n. 6
0
void Draw::DrawText(int x, int y, int angle, const wchar *text, Font font,
		            Color ink, int n, const int *dx)
{
#if defined(flagWINGL) || defined(flagLINUXGL)
	if(IsNull(ink))
		return;
	DrawTextOp(x, y, angle, text, font, ink, n, dx);
#else
	if(IsNull(ink)) return;
	if(n < 0)
		n = wstrlen(text);
	Std(font);
	double sina = 0;
	double cosa = 1;
	int    posx = 0;
	if(angle)
		Draw::SinCos(angle, sina, cosa);
	Font font0 = font;
	if(GetInfo() & DRAWTEXTLINES)
		font.Underline(false).Strikeout(false);
	for(int i = 0; i < n; i++) {
		wchar chr = text[i];
		GlyphInfo gi = GetGlyphInfo(font, chr);
		if(gi.IsNormal())
			if(angle)
				DrawTextOp(int(x + cosa * posx), int(y - sina * posx), angle, &chr, font, ink, 1, NULL);
			else {
				int c = 1;
				int dd = 0;
				while(i + c < n && c < 1000) {
					GlyphInfo gi2 = GetGlyphInfo(font, text[i + c]);
					if(!gi2.IsNormal())
						break;
					dd += dx ? dx[c - 1] : gi.width;
					c++;
					gi = gi2;
				}
				DrawTextOp(x + posx, y, 0, text + i, font, ink, c, dx);
				posx += dd;
				i += c - 1;
				if(dx)
					dx += c - 1;
			}
		else
		if(gi.IsReplaced()) {
			Font fnt = font;
			fnt.Face(gi.lspc);
			fnt.Height(gi.rspc);
			if(angle)
				DrawTextOp(int(x + cosa * posx), int(y - sina * (font.GetAscent() - fnt.GetAscent() + posx)),
				             angle, &chr, fnt, ink, 1, NULL);
			else
				DrawTextOp(x + posx, y + font.GetAscent() - fnt.GetAscent(), 0, &chr, fnt, ink, 1, NULL);
			GlyphMetrics(gi, font, chr);
		}
		else
		if(gi.IsComposed()) {
			ComposedGlyph cg;
			Compose(font, chr, cg);
			if(angle) {
				DrawTextOp(int(x + cosa * posx), int(y - sina * posx), angle, &cg.basic_char, font, ink, 1, NULL);
				DrawTextOp(int(x + cosa * (posx + cg.mark_pos.x)), int(y - sina * (cg.mark_pos.y + posx)), angle, &cg.mark_char, cg.mark_font, ink, 1, NULL);
			}
			else {
				DrawTextOp(x + posx, y, 0, &cg.basic_char, font, ink, 1, NULL);
				DrawTextOp(x + cg.mark_pos.x + posx, y + cg.mark_pos.y, 0, &cg.mark_char, cg.mark_font, ink, 1, NULL);
			}
			GlyphMetrics(gi, font, chr);
		}
		else {
			Font fnt = Arial(font.GetHeight());
			wchar chr = 0x25a1;
			gi = GetGlyphInfo(fnt, chr);
			if(!gi.IsNormal()) {
				chr = ' ';
				gi = GetGlyphInfo(fnt, chr);
			}
			if(angle)
				DrawTextOp(int(x + cosa * posx), int(y - sina * posx), angle, &chr, fnt, ink, 1, NULL);
			else
				DrawTextOp(x + posx, y, 0, &chr, fnt, ink, 1, NULL);
		}
		posx += dx ? *dx++ : gi.width;
	}

	if((GetInfo() & DRAWTEXTLINES) && (font0.IsUnderline() || font0.IsStrikeout())) {
		int hg = abs(font0.GetCy());
		if(hg == 0) hg = 10;
		int thickness = max(hg / 20, 1);

		int ascent = font0.GetAscent();
		Size offset = Point(0, ascent);
		if(angle) {
			offset.cx = fround(ascent * sina);
			offset.cy = fround(ascent * cosa);
		}

		x += offset.cx;
		y += offset.cy;
		if(font0.IsUnderline()) {
			int p = max(hg / 15, int(font0.Info().GetDescent() > 0));
			DrawLine(
				int(x + p * sina),
				int(y + p * cosa),
				int(x + posx * cosa + p * sina),
				int(y - posx * sina + p * cosa),
				thickness,
				ink
			);
		}
		if(font0.IsStrikeout()) {
			int p = -ascent / 3;
			DrawLine(
				int(x + p * sina),
				int(y + p * cosa),
				int(x + posx * cosa + p * sina),
				int(y - posx * sina + p * cosa),
				thickness,
				ink
			);
		}
	}

#endif
}
Esempio n. 7
0
void Draw::DrawText(int x, int y, int angle, const wchar *text, Font font,
		            Color ink, int n, const int *dx)
{
#ifdef flagWINGL
	if(IsNull(ink))
		return;
	DrawTextOp(x, y, angle, text, font, ink, n, dx);
#else
	if(IsNull(ink)) return;
	if(n < 0)
		n = wstrlen(text);
	Std(font);
	double sina;
	double cosa;
	int    d = 0;
	if(angle)
		Draw::SinCos(angle, sina, cosa);
	for(int i = 0; i < n; i++) {
		wchar chr = text[i];
		GlyphInfo gi = GetGlyphInfo(font, chr);
		if(gi.IsNormal())
			if(angle)
				DrawTextOp(int(x + cosa * d), int(y - sina * d), angle, &chr, font, ink, 1, NULL);
			else {
				int c = 1;
				int dd = 0;
				while(i + c < n) {
					GlyphInfo gi2 = GetGlyphInfo(font, text[i + c]);
					if(!gi2.IsNormal())
						break;
					dd += dx ? dx[c] : gi.width;
					c++;
					gi = gi2;
				}
				DrawTextOp(x + d, y, 0, text + i, font, ink, c, dx);
				d += dd;
				i += c - 1;
				if(dx)
					dx += c - 1;
			}
		else
		if(gi.IsReplaced()) {
			Font fnt = font;
			fnt.Face(gi.lspc);
			fnt.Height(gi.rspc);
			if(angle)
				DrawTextOp(int(x + cosa * d), int(y - sina * (font.GetAscent() - fnt.GetAscent() + d)),
				             angle, &chr, fnt, ink, 1, NULL);
			else
				DrawTextOp(x + d, y + font.GetAscent() - fnt.GetAscent(), 0, &chr, fnt, ink, 1, NULL);
			GlyphMetrics(gi, font, chr);
		}
		else
		if(gi.IsComposed()) {
			ComposedGlyph cg;
			Compose(font, chr, cg);
			if(angle) {
				DrawTextOp(int(x + cosa * d), int(y - sina * d), angle, &cg.basic_char, font, ink, 1, NULL);
				DrawTextOp(int(x + cosa * (d + cg.mark_pos.x)), int(y - sina * (cg.mark_pos.y + d)), angle, &cg.mark_char, cg.mark_font, ink, 1, NULL);
			}
			else {
				DrawTextOp(x + d, y, 0, &cg.basic_char, font, ink, 1, NULL);
				DrawTextOp(x + cg.mark_pos.x + d, y + cg.mark_pos.y, 0, &cg.mark_char, cg.mark_font, ink, 1, NULL);
			}
			GlyphMetrics(gi, font, chr);
		}
		else {
			Font fnt = Arial(font.GetHeight());
			wchar chr = 0x25a1;
			gi = GetGlyphInfo(fnt, chr);
			if(!gi.IsNormal()) {
				chr = ' ';
				gi = GetGlyphInfo(fnt, chr);
			}
			if(angle)
				DrawTextOp(int(x + cosa * d), int(y - sina * d), angle, &chr, fnt, ink, 1, NULL);
			else
				DrawTextOp(x + d, y, 0, &chr, fnt, ink, 1, NULL);
		}
		d += dx ? *dx++ : gi.width;
	}
#endif
}