/* Rotate a square image 90/270 degrees in place.  */
static void draw_buf_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t *color_p)
/* Rotate a square image 90/270 degrees in place.  */
static void draw_buf_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t *color_p)
{
    for(lv_coord_t i = 0; i < w / 2; i++) {
        for(lv_coord_t j = 0; j < (w + 1) / 2; j++) {
            lv_coord_t inv_i = (w - 1) - i;
            lv_coord_t inv_j = (w - 1) - j;
            if(is_270) {
                draw_buf_rotate4(
                    &color_p[i * w + j],
                    &color_p[inv_j * w + i],
                    &color_p[inv_i * w + inv_j],
                    &color_p[j * w + inv_i]
                );
            }
            else {
                draw_buf_rotate4(
                    &color_p[i * w + j],
                    &color_p[j * w + inv_i],
                    &color_p[inv_i * w + inv_j],
                    &color_p[inv_j * w + i]
                );
            }
        }
    }
}