void nxgl_circlepts(FAR const struct nxgl_point_s *center, nxgl_coord_t radius, FAR struct nxgl_point_s *circle) { nxgl_coord_t xoffs; nxgl_coord_t yoffs; /* 0, 90, 180, and 270 degrees are the easiest */ circle[POINT_0p0].x = center->x + radius; circle[POINT_0p0].y = center->y; circle[POINT_90p0].x = center->x; circle[POINT_90p0].y = center->y + radius; circle[POINT_180p0].x = center->x - radius; circle[POINT_180p0].y = center->y; circle[POINT_270p0].x = center->x; circle[POINT_270p0].y = center->y - radius; /* Now 22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, and 337.5 */ xoffs = b16toi(b16muli(COS_22p5, radius) + b16HALF); yoffs = b16toi(b16muli(SIN_22p5, radius) + b16HALF); circle[POINT_22p5].x = center->x + xoffs; circle[POINT_22p5].y = center->y + yoffs; circle[POINT_157p5].x = center->x - xoffs; circle[POINT_157p5].y = center->y + yoffs; circle[POINT_202p5].x = center->x - xoffs; circle[POINT_202p5].y = center->y - yoffs; circle[POINT_337p5].x = center->x + xoffs; circle[POINT_337p5].y = center->y - yoffs; circle[POINT_67p5].x = center->x + yoffs; circle[POINT_67p5].y = center->y + xoffs; circle[POINT_112p5].x = center->x - yoffs; circle[POINT_112p5].y = center->y + xoffs; circle[POINT_247p5].x = center->x - yoffs; circle[POINT_247p5].y = center->y - xoffs; circle[POINT_292p5].x = center->x + yoffs; circle[POINT_292p5].y = center->y - xoffs; /* Finally, 45.0, 135.0, 225.0, 315.0 */ xoffs = b16toi(b16muli(COS_45p0, radius) + b16HALF); circle[POINT_45p0].x = center->x + xoffs; circle[POINT_45p0].y = center->y + xoffs; circle[POINT_135p0].x = center->x - xoffs; circle[POINT_135p0].y = center->y + xoffs; circle[POINT_225p0].x = center->x - xoffs; circle[POINT_225p0].y = center->y - xoffs; circle[POINT_315p0].x = center->x + xoffs; circle[POINT_315p0].y = center->y - xoffs; }
void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b) { b16_t vm128 = itob16(v) - b16_128P0; b16_t um128 = itob16(u) - b16_128P0; /* Per the JFIF specification: * * R = Y + 1.40200 * (V - 128.0) * G = Y - 0.34414 * (U - 128.0) - 0.71414 * (V - 128.0) * B = Y + 1.77200 * (U - 128.0) */ *r = (uint8_t)b16toi(itob16(y) + b16muli(b16_1P402, vm128)); *g = (uint8_t)b16toi(itob16(y) - b16muli(b16_P3441, um128) - b16muli(b16_P7141, vm128)); *b = (uint8_t)b16toi(itob16(y) + b16muli(b16_1P772, um128)); }
void nxgl_rgb2yuv(uint8_t r, uint8_t g, uint8_t b, uint8_t *y, uint8_t *u, uint8_t *v) { /* Per the JFIF specification: * * Y = (0.2990 * R) + (0.5870 * G) + (0.1140 * B) * U = 128 - (0.1687 * R) - (0.3313 * G) + (0.5000 * B) * V = 128 + (0.5000 * R) - (0.4187 * G) - (0.0813 * B); */ *y = (uint8_t)b16toi(b16muli(b16_P2990, r) + b16muli(b16_P5870, g) + b16muli(b16_P1140, b)); *u = (uint8_t)b16toi(b16_128P0 - b16muli(b16_P1687, r) - b16muli(b16_P3313, g) + b16muli(b16_P5000, b)); *v = (uint8_t)b16toi(b16_128P0 + b16muli(b16_P5000, r) - b16muli(b16_P4187, g) - b16muli(b16_P0813, b)); }
void nxgl_circletraps(FAR const struct nxgl_point_s *center, nxgl_coord_t radius, FAR struct nxgl_trapezoid_s *circle) { nxgl_coord_t xoffs; nxgl_coord_t yoffs; circle[0].top.x1 = itob16(center->x); circle[0].top.x2 = circle[0].top.x1; circle[0].top.y = center->y - radius; circle[7].bot.x1 = circle[0].top.x1; circle[7].bot.x2 = circle[0].top.x1; circle[7].bot.y = center->y + radius; circle[3].bot.x1 = itob16(center->x - radius); circle[3].bot.x2 = itob16(center->x + radius); circle[3].bot.y = center->y; circle[4].top.x1 = circle[3].bot.x1; circle[4].top.x2 = circle[3].bot.x2; circle[4].top.y = circle[3].bot.y; /* Now 22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, and 337.5 */ xoffs = b16toi(b16muli(COS_22p5, radius) + b16HALF); yoffs = b16toi(b16muli(SIN_22p5, radius) + b16HALF); circle[2].bot.x1 = itob16(center->x - xoffs); circle[2].bot.x2 = itob16(center->x + xoffs); circle[2].bot.y = center->y - yoffs; circle[3].top.x1 = circle[2].bot.x1; circle[3].top.x2 = circle[2].bot.x2; circle[3].top.y = circle[2].bot.y; circle[4].bot.x1 = circle[2].bot.x1; circle[4].bot.x2 = circle[2].bot.x2; circle[4].bot.y = center->y + yoffs; circle[5].top.x1 = circle[4].bot.x1; circle[5].top.x2 = circle[4].bot.x2; circle[5].top.y = circle[4].bot.y; circle[0].bot.x1 = itob16(center->x - yoffs); circle[0].bot.x2 = itob16(center->x + yoffs); circle[0].bot.y = center->y - xoffs; circle[1].top.x1 = circle[0].bot.x1; circle[1].top.x2 = circle[0].bot.x2; circle[1].top.y = circle[0].bot.y; circle[6].bot.x1 = circle[1].top.x1; circle[6].bot.x2 = circle[1].top.x2; circle[6].bot.y = center->y + xoffs; circle[7].top.x1 = circle[6].bot.x1; circle[7].top.x2 = circle[6].bot.x2; circle[7].top.y = circle[6].bot.y; /* Finally, 45.0, 135.0, 225.0, 315.0 */ xoffs = b16toi(b16muli(COS_45p0, radius) + b16HALF); circle[1].bot.x1 = itob16(center->x - xoffs); circle[1].bot.x2 = itob16(center->x + xoffs); circle[1].bot.y = center->y - xoffs; circle[2].top.x1 = circle[1].bot.x1; circle[2].top.x2 = circle[1].bot.x2; circle[2].top.y = circle[1].bot.y; circle[5].bot.x1 = circle[1].bot.x1; circle[5].bot.x2 = circle[1].bot.x2; circle[5].bot.y = center->y + xoffs; circle[6].top.x1 = circle[5].bot.x1; circle[6].top.x2 = circle[5].bot.x2; circle[6].top.y = circle[5].bot.y; }