コード例 #1
0
e_int32 dm_alloc_buffer(data_manager_t *dm, int buf_type, point_t **pnt_buf,
		point_t **gray_buf) {
	e_assert(dm&&dm->state, E_ERROR_INVALID_HANDLER);
	if (DATA_BLOCK_TYPE_COLUMN == buf_type) {
		if (dm->points_xyz)
			free(dm->points_xyz);
		if (dm->points_gray)
			free(dm->points_gray);
		dm->points_xyz = malloc_points(PNT_TYPE_POLAR, dm->height);
		dm->points_gray = malloc_points(PNT_TYPE_GRAY, dm->height);
	} else {
		return E_ERROR_INVALID_PARAMETER;
	}

	dm->buf_type = buf_type;
	(*pnt_buf) = dm->points_xyz;
	(*gray_buf) = dm->points_gray;
	e_assert(dm->points_xyz && dm->points_gray, E_ERROR_BAD_ALLOCATE);
	return E_OK;
}
コード例 #2
0
int main()
{
	data_adapter_t da;
	unsigned char file_name[][64] = { "test.pcd1", "test.jpg", "test.gif",
			"/data/local/tmp/test.sprite" };

	da_open(&da, file_name[3], W, H, E_DWRITE); //data_adapter_t *da, e_uint8 *name, int mode

	point_array = malloc_points(PNT_TYPE_GRAY,H);
	points_gray = (point_gray_t*)point_array->mem;

	for (int i = 0; i < H; i++)
		points_gray[i].gray = 80;

	for (int i = 0; i < W; i++)
		da_write_column(&da,i, point_array, 0);

	for (int i = 0; i < H; i++)
		points_gray[i].gray = 160;

	for (int i = 0; i < W; i++)
		da_write_column(&da, W - i - 1, point_array, 1);

//	point_array = malloc_points(PNT_TYPE_XYZ, H);
//	points = (point_xyz_t*) point_array->mem;
//
//	for (int i = 0; i < H; i++) {
//		points[i].x = H * sin(i * M_PI / H);
//		points[i].y = H * cos(i * M_PI / H);
//		points[i].z = H * sin(M_PI - i * M_PI / H);
//	}
//
//	for (int i = 0; i < W; i++)
//		da_append_points(&da, point_array, H, 0);
//
//	for (int i = 0; i < H; i++) {
//		points[i].x += 100;
//		points[i].y += 100;
//		points[i].z += 100;
//	}
//
//	for (int i = 0; i < W; i++)
//		da_append_points(&da, point_array, H, 1);
//
	da_close(&da);
	free_points(point_array);
	printf("ALL TEST PASSED!\n");
	return 0;
}