Copy a smaller or equally sized image into a destination buffer at a given offset. Assumes that the source image fits completely within the destination at the specified offset. It assumes both source and destination use the RGB888 format. \param src Pointer to the source image buffer. \param src_width Width of the source image in pixels. \param src_height Height of the source i
| 39 | \param format Pixel format for both source and destination (must match). |
| 40 | */ |
| 41 | static void copy_RGB888(const uint8_t *src, |
| 42 | int src_width, |
| 43 | int src_height, |
| 44 | uint8_t *dst, |
| 45 | int dst_width, |
| 46 | int dst_height, |
| 47 | int x_offset, |
| 48 | int y_offset) { |
| 49 | int bpp = 3; |
| 50 | |
| 51 | for (int y = 0; y < src_height; ++y) { |
| 52 | int dst_y = y + y_offset; |
| 53 | if (dst_y < 0 || dst_y >= dst_height) |
| 54 | continue; |
| 55 | |
| 56 | for (int x = 0; x < src_width; ++x) { |
| 57 | int dst_x = x + x_offset; |
| 58 | if (dst_x < 0 || dst_x >= dst_width) |
| 59 | continue; |
| 60 | |
| 61 | int src_idx = (y * src_width + x) * bpp; |
| 62 | int dst_idx = (dst_y * dst_width + dst_x) * bpp; |
| 63 | |
| 64 | for (int i = 0; i < bpp; ++i) { |
| 65 | dst[dst_idx + i] = src[src_idx + i]; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | \brief Crop a region from an RGB888 image. |