@@ -269,6 +269,9 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, l
269
269
270
270
/**
271
271
* Rotate and image and store the result on a canvas.
272
+ *
273
+ * NOTE: When doing 90, 180 or 270 degree rotations, using pivot point 0,0 will do a perfect rotation.
274
+ *
272
275
* @param canvas pointer to a canvas object
273
276
* @param img pointer to an image descriptor.
274
277
* Can be the image descriptor of an other canvas too (`lv_canvas_get_img()`).
@@ -314,6 +317,26 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_c
314
317
lv_img_buf_set_px_color (& ext_dst -> dsc , x + offset_x , y + offset_y , color_res );
315
318
continue ;
316
319
}
320
+ if ((angle == 270 || angle == 90 ) && pivot_x == 0 && pivot_y == 0 ) {
321
+ int32_t source_x = x + offset_x ;
322
+ int32_t source_y = y + offset_y ;
323
+ int32_t dest_x = x + offset_x ;
324
+ int32_t dest_y = y + offset_y ;
325
+
326
+ if (angle == 90 ) {
327
+ source_x = img_height - 1 - (x + offset_x );
328
+ }
329
+ else {
330
+ source_y = img_width - 1 - (y + offset_y );
331
+ }
332
+
333
+ lv_color_t color_res = lv_img_buf_get_px_color (img , source_y , source_x , style );
334
+
335
+ lv_img_buf_set_px_color (& ext_dst -> dsc , dest_x , dest_y , color_res );
336
+
337
+ continue ;
338
+ }
339
+
317
340
/*Get the target point relative coordinates to the pivot*/
318
341
int32_t xt = x - pivot_x ;
319
342
int32_t yt = y - pivot_y ;
0 commit comments