在Android层实现触摸屏校验
2010-05-31 14:35:00 来源:WEB开发网for (j = 0; j < 5; j++) {
z += (float)cal.xfb[j];
zx += (float)(cal.xfb[j] * cal.x[j]);
zy += (float)(cal.xfb[j] * cal.y[j]);
}
// Now multiply out to get the calibration for framebuffer x coord
cal.a[0] = (int)((a * z + b * zx + c * zy) * (scaling));
cal.a[1] = (int)((b * z + e * zx + f * zy) * (scaling));
cal.a[2] = (int)((c * z + f * zx + i * zy) * (scaling));
System.out.printf("%f %f %f ", (a * z + b * zx + c * zy), (b * z + e * zx + f * zy), (c
* z + f * zx + i * zy));
// Get sums for y calibration
z = zx = zy = 0;
for (j = 0; j < 5; j++) {
z += (float)cal.yfb[j];
zx += (float)(cal.yfb[j] * cal.x[j]);
zy += (float)(cal.yfb[j] * cal.y[j]);
}
// Now multiply out to get the calibration for framebuffer y coord
cal.a[3] = (int)((a * z + b * zx + c * zy) * (scaling));
cal.a[4] = (int)((b * z + e * zx + f * zy) * (scaling));
cal.a[5] = (int)((c * z + f * zx + i * zy) * (scaling));
System.out.printf("%f %f %f ", (a * z + b * zx + c * zy), (b * z + e * zx + f * zy), (c
* z + f * zx + i * zy));
// If we got here, we're OK, so assign scaling to a[6] and return
cal.a[6] = (int)scaling;
return true;
/*
* // This code was here originally to just insert default values
* for(j=0;j<7;j++) { c->a[j]=0; } c->a[1] = c->a[5] = c->a[6] = 1;
* return 1;
*/
}
void get_sample(int index, int x1, int y1, int x, int y) {
Log.i("XXW", "get_sample");
cal.x[index] = x1;
cal.y[index] = y1;
cal.xfb[index] = x;
cal.yfb[index] = y;
}
int calibrate_main() {
int result = 0;
Log.i("XXW", "calibrate_main");
更多精彩
赞助商链接