示例#1
0
文件: tpcal.c 项目: LucidOne/Rovio
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	PAINTSTRUCT ps;
	HDC hdc;
  
	switch(msg) {
		case WM_PAINT:
			hdc = BeginPaint(hwnd, &ps);
			DoPaint(hdc);
			EndPaint(hwnd, &ps);
			break;

		case WM_NCHITTEST:
			return HTCLIENT;

		case WM_LBUTTONUP:
			if ( pcp != 0 )
			{
				pcp->screen.x = current_target_location.x * TRANSFORMATION_UNITS_PER_PIXEL;
				pcp->screen.y = current_target_location.y * TRANSFORMATION_UNITS_PER_PIXEL;
				pcp->device.x = GET_X_LPARAM(lp);
				pcp->device.y = GET_Y_LPARAM(lp);
			}

			if ( ++current_target == total_targets )
			{
				TRANSFORMATION_COEFFICIENTS tc;
#if 0
				CalcTransformationCoefficientsSimple(&cps, &tc);
				printf("%d %d %d %d %d %d %d\n",
					tc.a, tc.b, tc.c, tc.d, tc.e, tc.f, tc.s);
				CalcTransformationCoefficientsBetter(&cps, &tc);
				printf("%d %d %d %d %d %d %d\n",
					tc.a, tc.b, tc.c, tc.d, tc.e, tc.f, tc.s);
				CalcTransformationCoefficientsEvenBetter(&cps, &tc);
				printf("%d %d %d %d %d %d %d\n",
					tc.a, tc.b, tc.c, tc.d, tc.e, tc.f, tc.s);
#endif
				CalcTransformationCoefficientsBest(&cps, &tc);
				printf("%d %d %d %d %d %d %d\n",
					tc.a, tc.b, tc.c, tc.d, tc.e, tc.f, tc.s);
				InvalidateRect(hwnd, NULL, TRUE);
				UpdateWindow(hwnd);
				PostQuitMessage(0);
				break;
			}
			InvalidateRect(hwnd, NULL, TRUE);
			UpdateWindow(hwnd);
			break;

		default:
			return DefWindowProc(hwnd, msg, wp, lp);
	}

	return 0;
}
示例#2
0
int
GrCalcTransform(GR_CAL_DATA * data, GR_TRANSFORM * trans)
{
	return CalcTransformationCoefficientsBetter(data, trans);
}