How to update style of an image

Hi everyone,
I need to update the style of an image. For instance, there is a left signal indicator in my screen, which is only white image and its opacity is 50 by default, when get the message from UART, then have to change its value as OPA_100. How can I do this? Where can I update its value, for example in while loop it can be? Please give me an example.

While trying the following code in PC simulator in ubuntu with Eclipse IDE, there is no changes for image?

	while(1) {
		/* Periodically call the lv_task handler.
		 * It could be done in a timer interrupt or an OS task too.*/
		usleep(5 * 1000);

		if(b_state_on == 1){
			lv_style_set_img_recolor(&style_icon_left_right, lv_color_make(0xb2, 0x01, 0x01));
			lv_style_set_img_recolor_opa(&style_icon_left_right, LV_OPA_100);
			lv_style_set_img_recolor(&style_icon_left_right, lv_color_make(0xff, 0xff, 0xff));
			lv_style_set_img_recolor_opa(&style_icon_left_right, LV_OPA_50);

If you apply style_icon_left_right style to your image, then shoud notify image about style changes

Thank you, which one should I use for best performance?( lv_obj_invalidate(obj), lv_obj_refresh_style(obj, part, property), lv_obj_report_style_change(&style))
Also, can I change style in while loop, can’t it?

If you use this style only for one obj, and you want to change opacity of whole image, than image must be redrawn anyway - lv_obj_invalidate().