21 static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame);
22 static int saveBA81(
FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame);
58 if (return_value == 0) {
59 return_value =
renderBA81(x, y, xwidth, ywidth, size, videodata);
97 if (return_value == 0) {
98 return_value =
saveBA81(handle, xwidth, ywidth, size, videodata);
108 static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t* pixel, uint8_t* r, uint8_t* g, uint8_t* b)
113 *g = (*(pixel - 1) + * (pixel + 1) + * (pixel + width) + * (pixel - width)) >> 2;
114 *b = (*(pixel - width - 1) + * (pixel - width + 1) + * (pixel + width - 1) + * (pixel + width + 1)) >> 2;
116 *r = (*(pixel - 1) + * (pixel + 1)) >> 1;
118 *b = (*(pixel - width) + * (pixel + width)) >> 1;
122 *r = (*(pixel - width) + * (pixel + width)) >> 1;
124 *b = (*(pixel - 1) + * (pixel + 1)) >> 1;
126 *r = (*(pixel - width - 1) + * (pixel - width + 1) + * (pixel + width - 1) + * (pixel + width + 1)) >> 2;
127 *g = (*(pixel - 1) + * (pixel + 1) + * (pixel + width) + * (pixel - width)) >> 2;
139 static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame)
151 uint16_t* decodedimage = malloc(
sizeof(uint16_t) * (width - 2) * (height - 2));
153 if (decodedimage == NULL) {
155 for (y = 1; y < height - 1; y++) {
158 for (x = 1; x < width - 1; x++, frame++) {
166 uint16_t* line = decodedimage;
168 for (y = 1; y < height - 1; y++) {
172 for (x = 1; x < width - 1; x++, frame++) {
175 *line++ =
RGB(r, g, b);
189 static int saveBA81(
FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame)
194 uint32_t fpos = handle->
fpos;
195 uint32_t row_size_padded = ((width - 2) * 3 + 3) & (~3);
196 uint32_t fpos_end = fpos + row_size_padded * (height - 2);
205 for (y = 1; y < height - 1; y++) {
207 uint8_t rowbuf[row_size_padded];
214 for (x = 1; x < width - 1; x++, frame++) {
217 rowbuf[(x - 1) * 3] = b;
218 rowbuf[(x - 1) * 3 + 1] = g;
219 rowbuf[(x - 1) * 3 + 2] = r;
233 int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
static int saveBA81(FILE_HANDLE *handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
int pixy_save_cropped_frame(FILE_HANDLE *handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
int pixy_save_full_frame(FILE_HANDLE *handle)
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat)
static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t *pixel, uint8_t *r, uint8_t *g, uint8_t *b)
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
int pixy_command(const char *name,...)
Send a command to Pixy.
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
uint32_t fpos
The current byte-position in the file.
int pixy_render_full_frame(uint16_t x, uint16_t y)
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)