diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_test.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_test.py index efebb4494..5b3ea1817 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_test.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_test.py @@ -46,7 +46,7 @@ big_img.draw_image(small_img, 0, 0, x_scale=32, y_scale=32, hint=hint) alpha_div = 1 alpha_value = 0 -alpha_step = 2 +alpha_step = 3 x_bounce = sensor.width() // 2 x_bounce_toggle = 1 @@ -79,7 +79,7 @@ while True: y_bounce_toggle = -y_bounce_toggle alpha_value += alpha_step - if not alpha_value or alpha_value // alpha_div == 256: + if not alpha_value or alpha_value // alpha_div >= 255: alpha_step = -alpha_step print(clock.fps()) diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py index f6d4bb585..cd9e0c07e 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_blending_with_color_table_test.py @@ -56,7 +56,7 @@ big_img.draw_image(small_img, 0, 0, x_scale=32, y_scale=32, hint=hint) alpha_div = 1 alpha_value = 0 -alpha_step = 2 +alpha_step = 3 x_bounce = sensor.width() // 2 x_bounce_toggle = 1 @@ -90,7 +90,7 @@ while True: y_bounce_toggle = -y_bounce_toggle alpha_value += alpha_step - if not alpha_value or alpha_value // alpha_div == 256: + if not alpha_value or alpha_value // alpha_div >= 255: alpha_step = -alpha_step print(clock.fps()) diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_test.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_test.py index 58a0c1089..555f73c4a 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_test.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_test.py @@ -50,7 +50,7 @@ for i in range(256): alpha_div = 1 alpha_value = 0 -alpha_step = 2 +alpha_step = 3 x_bounce = sensor.width() // 2 x_bounce_toggle = 1 @@ -84,7 +84,7 @@ while True: y_bounce_toggle = -y_bounce_toggle alpha_value += alpha_step - if not alpha_value or alpha_value // alpha_div == 256: + if not alpha_value or alpha_value // alpha_div >= 255: alpha_step = -alpha_step print(clock.fps()) diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py index 9fa444636..7bbdb0999 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_alpha_table_with_color_table_test.py @@ -60,7 +60,7 @@ for i in range(256): alpha_div = 1 alpha_value = 0 -alpha_step = 2 +alpha_step = 3 x_bounce = sensor.width() // 2 x_bounce_toggle = 1 @@ -95,7 +95,7 @@ while True: y_bounce_toggle = -y_bounce_toggle alpha_value += alpha_step - if not alpha_value or alpha_value // alpha_div == 256: + if not alpha_value or alpha_value // alpha_div >= 255: alpha_step = -alpha_step print(clock.fps()) diff --git a/scripts/examples/02-Image-Processing/03-Frame-Differencing/in_memory_advanced_frame_differencing.py b/scripts/examples/02-Image-Processing/03-Frame-Differencing/in_memory_advanced_frame_differencing.py index 44edbd4ce..bb220a9da 100644 --- a/scripts/examples/02-Image-Processing/03-Frame-Differencing/in_memory_advanced_frame_differencing.py +++ b/scripts/examples/02-Image-Processing/03-Frame-Differencing/in_memory_advanced_frame_differencing.py @@ -14,7 +14,7 @@ import time TRIGGER_THRESHOLD = 5 BG_UPDATE_FRAMES = 50 # How many frames before blending. -BG_UPDATE_BLEND = 128 # How much to blend by... ([0-256]==[0.0-1.0]). +BG_UPDATE_BLEND = 128 # How much to blend by... ([0-255]==[0.0-1.0]). sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.RGB565 @@ -44,15 +44,15 @@ while True: img = sensor.snapshot() # Take a picture and return the image. frame_count += 1 - if frame_count > BG_UPDATE_FRAMES and not triggered: + if frame_count > BG_UPDATE_FRAMES: frame_count = 0 - # Blend in new frame. We're doing 256-alpha here because we want to + # Blend in new frame. We're doing 255-alpha here because we want to # blend the new frame into the background. Not the background into the # new frame which would be just alpha. Blend replaces each pixel by - # ((NEW*(alpha))+(OLD*(256-alpha)))/256. So, a low alpha results in + # ((NEW*(alpha))+(OLD*(255-alpha)))/255. So, a low alpha results in # low blending of the new image while a high alpha results in high # blending of the new image. We need to reverse that for this update. - img.blend(extra_fb, alpha=(256 - BG_UPDATE_BLEND)) + img.blend(extra_fb, alpha=(255 - BG_UPDATE_BLEND)) extra_fb.replace(img) # Replace the image with the "abs(NEW-OLD)" frame difference. diff --git a/scripts/examples/02-Image-Processing/03-Frame-Differencing/on_disk_advanced_frame_differencing.py b/scripts/examples/02-Image-Processing/03-Frame-Differencing/on_disk_advanced_frame_differencing.py index 10bc75568..a2c8dd171 100644 --- a/scripts/examples/02-Image-Processing/03-Frame-Differencing/on_disk_advanced_frame_differencing.py +++ b/scripts/examples/02-Image-Processing/03-Frame-Differencing/on_disk_advanced_frame_differencing.py @@ -17,7 +17,7 @@ import time TRIGGER_THRESHOLD = 5 BG_UPDATE_FRAMES = 50 # How many frames before blending. -BG_UPDATE_BLEND = 128 # How much to blend by... ([0-256]==[0.0-1.0]). +BG_UPDATE_BLEND = 128 # How much to blend by... ([0-255]==[0.0-1.0]). sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.RGB565 @@ -42,15 +42,15 @@ while True: img = sensor.snapshot() # Take a picture and return the image. frame_count += 1 - if frame_count > BG_UPDATE_FRAMES and not triggered: + if frame_count > BG_UPDATE_FRAMES: frame_count = 0 - # Blend in new frame. We're doing 256-alpha here because we want to + # Blend in new frame. We're doing 255-alpha here because we want to # blend the new frame into the background. Not the background into the # new frame which would be just alpha. Blend replaces each pixel by - # ((NEW*(alpha))+(OLD*(256-alpha)))/256. So, a low alpha results in + # ((NEW*(alpha))+(OLD*(255-alpha)))/255. So, a low alpha results in # low blending of the new image while a high alpha results in high # blending of the new image. We need to reverse that for this update. - img.blend("temp/bg.bmp", alpha=(256 - BG_UPDATE_BLEND)) + img.blend("temp/bg.bmp", alpha=(255 - BG_UPDATE_BLEND)) img.save("temp/bg.bmp") # Replace the image with the "abs(NEW-OLD)" frame difference. diff --git a/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay.py b/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay.py index 2cde87da3..56787717b 100644 --- a/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay.py +++ b/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay.py @@ -53,7 +53,7 @@ while True: else: # Create a secondary image and then blend into the frame buffer. extra_fb.clear() - fir.draw_ir(extra_fb, ir, alpha=256, hint=drawing_hint) + fir.draw_ir(extra_fb, ir, hint=drawing_hint) img.blend(extra_fb, alpha=128) # Draw ambient, min and max temperatures. diff --git a/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay_lcd.py b/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay_lcd.py index cc39d31fd..c2f369c21 100644 --- a/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay_lcd.py +++ b/scripts/examples/50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay_lcd.py @@ -57,7 +57,7 @@ while True: else: # Create a secondary image and then blend into the frame buffer. extra_fb.clear() - fir.draw_ir(extra_fb, ir, alpha=256, hint=drawing_hint) + fir.draw_ir(extra_fb, ir, hint=drawing_hint) img.blend(extra_fb, alpha=128) # Draw ambient, min and max temperatures. diff --git a/src/omv/common/omv_gpu.h b/src/omv/common/omv_gpu.h index 52c17fe88..9af11e030 100644 --- a/src/omv/common/omv_gpu.h +++ b/src/omv/common/omv_gpu.h @@ -32,7 +32,7 @@ void omv_gpu_deinit(); // Draws src_rect from src_img to dst_rect in dst_img. // If the sizes of src_rect and dst_rect are different then the image must be scaled. -// Alpha is the alpha value (0-256) to use when blending the source image with the destination image. +// Alpha is the alpha value (0-255) to use when blending the source image with the destination image. // If color_palette is not NULL, it is used to map the source image's 8-bit Y to an 16-bit RGB565 color. // If alpha_palette is not NULL, it is used to map the source image's 8-bit Y to an 8-bit alpha value. // diff --git a/src/omv/imlib/apriltag.c b/src/omv/imlib/apriltag.c index 2a0b0bde1..53a84496c 100644 --- a/src/omv/imlib/apriltag.c +++ b/src/omv/imlib/apriltag.c @@ -11995,7 +11995,7 @@ void imlib_find_apriltags(list_t *out, image_t *ptr, rectangle_t *roi, apriltag_ img.h = roi->h; img.pixfmt = PIXFORMAT_GRAYSCALE; img.data = fb_alloc(image_size(&img), FB_ALLOC_NO_HINT); - imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 256, NULL, NULL, 0, NULL, NULL, NULL); + imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 255, NULL, NULL, 0, NULL, NULL, NULL); image_u8_t im; im.width = roi->w; @@ -12111,7 +12111,7 @@ void imlib_find_rects(list_t *out, image_t *ptr, rectangle_t *roi, uint32_t thre img.h = roi->h; img.pixfmt = PIXFORMAT_GRAYSCALE; img.data = fb_alloc(image_size(&img), FB_ALLOC_NO_HINT); - imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 256, NULL, NULL, 0, NULL, NULL, NULL); + imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 255, NULL, NULL, 0, NULL, NULL, NULL); image_u8_t im; im.width = roi->w; diff --git a/src/omv/imlib/binary.c b/src/omv/imlib/binary.c index dd0ede992..651fcd382 100644 --- a/src/omv/imlib/binary.c +++ b/src/omv/imlib/binary.c @@ -200,7 +200,7 @@ void imlib_binary(image_t *out, image_t *img, list_t *thresholds, bool invert, b dst_row_override = fb_alloc0(image_line_size(out), FB_ALLOC_CACHE_ALIGN); } - imlib_draw_image(out, &bmp, 0, 0, 1.0f, 1.0f, NULL, -1, 256, NULL, NULL, 0, callback, mask, dst_row_override); + imlib_draw_image(out, &bmp, 0, 0, 1.0f, 1.0f, NULL, -1, 255, NULL, NULL, 0, callback, mask, dst_row_override); if (dst_row_override) { fb_free(); // dst_row_override @@ -1255,7 +1255,7 @@ static void imlib_hat(image_t *img, int ksize, int threshold, image_t *mask, bin memcpy(temp.data, img->data, image_size(img)); op(&temp, ksize, threshold, mask); void *dst_row_override = fb_alloc0(image_line_size(img), FB_ALLOC_CACHE_ALIGN); - imlib_draw_image(img, &temp, 0, 0, 1.0f, 1.0f, NULL, -1, 256, NULL, NULL, 0, + imlib_draw_image(img, &temp, 0, 0, 1.0f, 1.0f, NULL, -1, 255, NULL, NULL, 0, imlib_difference_line_op, mask, dst_row_override); fb_free(); // dst_row_override fb_free(); // temp.data diff --git a/src/omv/imlib/dmtx.c b/src/omv/imlib/dmtx.c index e0b6f28c2..0799fc33d 100644 --- a/src/omv/imlib/dmtx.c +++ b/src/omv/imlib/dmtx.c @@ -6016,7 +6016,7 @@ void imlib_find_datamatrices(list_t *out, image_t *ptr, rectangle_t *roi, int ef img.h = roi->h; img.pixfmt = PIXFORMAT_GRAYSCALE; img.data = grayscale_image; - imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 256, NULL, NULL, 0, NULL, NULL, NULL); + imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 255, NULL, NULL, 0, NULL, NULL, NULL); } umm_init_x(fb_avail()); diff --git a/src/omv/imlib/draw.c b/src/omv/imlib/draw.c index 17e4d5cc6..ebf0d1fe2 100644 --- a/src/omv/imlib/draw.c +++ b/src/omv/imlib/draw.c @@ -722,6 +722,9 @@ void imlib_draw_row_setup(imlib_draw_row_data_t *data) { int alpha = data->alpha, max = 256; + // To avoid having to divide by 255 scale alpha to 0-256 so we can right shift by 8. + alpha = fast_roundf((alpha * 256) / 255.0f); + if (data->dst_img->pixfmt == PIXFORMAT_RGB565) { alpha >>= 3; // 5-bit alpha for RGB565 max = 32; @@ -733,7 +736,7 @@ void imlib_draw_row_setup(imlib_draw_row_data_t *data) { data->smuad_alpha_palette = fb_alloc(256 * sizeof(uint32_t), FB_ALLOC_NO_HINT); for (int i = 0, a = alpha; i < 256; i++) { - int new_alpha = fast_roundf((a * data->alpha_palette[i]) / 255.f); + int new_alpha = fast_roundf((a * data->alpha_palette[i]) / 255.0f); data->smuad_alpha_palette[i] = data->black_background ? new_alpha : ((new_alpha << 16) | (max - new_alpha)); } } else { @@ -836,7 +839,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = IMAGE_GET_BINARY_PIXEL_FAST(src32, x); @@ -1021,7 +1024,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src8++ > 127; @@ -1139,7 +1142,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -1257,7 +1260,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -1375,7 +1378,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -1493,7 +1496,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -1616,7 +1619,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { *dst8++ = @@ -1709,7 +1712,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { unaligned_memcpy(dst8, src8, (x_end - x_start) * sizeof(uint8_t)); } else { @@ -1793,7 +1796,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -1881,7 +1884,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -1969,7 +1972,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -2057,7 +2060,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -2163,7 +2166,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { *dst16++ = @@ -2254,7 +2257,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src8++; @@ -2342,7 +2345,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { unaligned_memcpy(dst16, src16, (x_end - x_start) * sizeof(uint16_t)); } else { @@ -2428,7 +2431,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -2522,7 +2525,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -2616,7 +2619,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da } } } - } else if (data->alpha == 256) { + } else if (data->alpha == 255) { if (!data->color_palette) { for (int x = x_start; x < x_end; x++) { int pixel = *src16++; @@ -3031,7 +3034,7 @@ void imlib_draw_image(image_t *dst_img, new_src_img.pixfmt = color_palette ? PIXFORMAT_RGB565 : PIXFORMAT_GRAYSCALE; new_src_img.data = fb_alloc(image_size(&new_src_img), FB_ALLOC_CACHE_ALIGN); imlib_draw_image(&new_src_img, src_img, 0, 0, 1.f, 1.f, NULL, - rgb_channel, 256, color_palette, NULL, 0, NULL, NULL, NULL); + rgb_channel, 255, color_palette, NULL, 0, NULL, NULL, NULL); src_img = &new_src_img; rgb_channel = -1; color_palette = NULL; @@ -3131,7 +3134,7 @@ void imlib_draw_image(image_t *dst_img, t_src_img.h = t_roi.h = src_width_scaled; // was transposed t_src_img.data = fb_alloc(image_size(&t_src_img), FB_ALLOC_CACHE_ALIGN); imlib_draw_image(&t_src_img, src_img, 0, 0, x_scale, y_scale, roi, - -1, 256, NULL, NULL, + -1, 255, NULL, NULL, hint & (IMAGE_HINT_AREA | IMAGE_HINT_BILINEAR | IMAGE_HINT_BICUBIC), NULL, NULL, NULL); } else { diff --git a/src/omv/imlib/lsd.c b/src/omv/imlib/lsd.c index cf7c12ba6..5b9047132 100644 --- a/src/omv/imlib/lsd.c +++ b/src/omv/imlib/lsd.c @@ -2699,7 +2699,7 @@ void imlib_lsd_find_line_segments(list_t *out, img.h = roi->h; img.pixfmt = PIXFORMAT_GRAYSCALE; img.data = grayscale_image; - imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 256, NULL, NULL, 0, NULL, NULL, NULL); + imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 255, NULL, NULL, 0, NULL, NULL, NULL); umm_init_x(fb_avail()); diff --git a/src/omv/imlib/mjpeg.c b/src/omv/imlib/mjpeg.c index c29e6ed75..5f6d458ce 100644 --- a/src/omv/imlib/mjpeg.c +++ b/src/omv/imlib/mjpeg.c @@ -131,7 +131,7 @@ void mjpeg_write(FIL *fp, int width, int height, uint32_t *frames, uint32_t *byt (roi->w == img->w) && (roi->h == img->h) && (rgb_channel == -1) && - (alpha == 256) && + (alpha == 255) && (color_palette == NULL) && (alpha_palette == NULL); diff --git a/src/omv/imlib/qrcode.c b/src/omv/imlib/qrcode.c index f893765cb..939317ce3 100644 --- a/src/omv/imlib/qrcode.c +++ b/src/omv/imlib/qrcode.c @@ -2984,7 +2984,7 @@ void imlib_find_qrcodes(list_t *out, image_t *ptr, rectangle_t *roi) img.h = roi->h; img.pixfmt = PIXFORMAT_GRAYSCALE; img.data = grayscale_image; - imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 256, NULL, NULL, 0, NULL, NULL, NULL); + imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 255, NULL, NULL, 0, NULL, NULL, NULL); quirc_end(controller); list_init(out, sizeof(find_qrcodes_list_lnk_data_t)); diff --git a/src/omv/imlib/zbar.c b/src/omv/imlib/zbar.c index 53d18f0cc..7555ffff3 100644 --- a/src/omv/imlib/zbar.c +++ b/src/omv/imlib/zbar.c @@ -8733,7 +8733,7 @@ void imlib_find_barcodes(list_t *out, image_t *ptr, rectangle_t *roi) img.h = roi->h; img.pixfmt = PIXFORMAT_GRAYSCALE; img.data = grayscale_image; - imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 256, NULL, NULL, 0, NULL, NULL, NULL); + imlib_draw_image(&img, ptr, 0, 0, 1.f, 1.f, roi, -1, 255, NULL, NULL, 0, NULL, NULL, NULL); } umm_init_x(fb_avail()); diff --git a/src/omv/modules/py_display.c b/src/omv/modules/py_display.c index 6d6a1f0aa..8e676f7de 100644 --- a/src/omv/modules/py_display.c +++ b/src/omv/modules/py_display.c @@ -149,7 +149,7 @@ static mp_obj_t py_display_write(uint n_args, const mp_obj_t *pos_args, mp_map_t { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -168,8 +168,8 @@ static mp_obj_t py_display_write(uint n_args, const mp_obj_t *pos_args, mp_map_t mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } float x_scale = 1.0f; diff --git a/src/omv/modules/py_fir.c b/src/omv/modules/py_fir.c index cb9df867d..b1ab23cd5 100644 --- a/src/omv/modules/py_fir.c +++ b/src/omv/modules/py_fir.c @@ -899,7 +899,7 @@ mp_obj_t py_fir_draw_ir(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_INT(COLOR_PALETTE_RAINBOW)} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -919,8 +919,8 @@ mp_obj_t py_fir_draw_ir(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } image_t src_img = { @@ -975,7 +975,7 @@ mp_obj_t py_fir_snapshot(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_INT(COLOR_PALETTE_RAINBOW)} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -994,8 +994,8 @@ mp_obj_t py_fir_snapshot(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } if ((args[ARG_pixformat].u_int != PIXFORMAT_GRAYSCALE) && (args[ARG_pixformat].u_int != PIXFORMAT_RGB565)) { diff --git a/src/omv/modules/py_image.c b/src/omv/modules/py_image.c index 154169b2b..e910c35bd 100644 --- a/src/omv/modules/py_image.c +++ b/src/omv/modules/py_image.c @@ -1006,7 +1006,7 @@ static mp_obj_t py_image_to(pixformat_t pixfmt, mp_rom_obj_t default_color_palet { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = default_color_palette} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -1028,8 +1028,8 @@ static mp_obj_t py_image_to(pixformat_t pixfmt, mp_rom_obj_t default_color_palet mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } if (args[ARG_quality].u_int < 1 || args[ARG_quality].u_int > 100) { @@ -1074,7 +1074,7 @@ static mp_obj_t py_image_to(pixformat_t pixfmt, mp_rom_obj_t default_color_palet (((x_scale != 1.0f) && (x_scale != -1.0f)) || ((y_scale != 1.0f) && (y_scale != -1.0f)) || (args[ARG_channel].u_int != -1) || - (args[ARG_alpha].u_int != 256) || + (args[ARG_alpha].u_int != 255) || (color_palette != NULL) || (alpha_palette != NULL))) { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Only copying/cropping is supported for Bayer/YUV!")); } @@ -1107,7 +1107,7 @@ static mp_obj_t py_image_to(pixformat_t pixfmt, mp_rom_obj_t default_color_palet (roi.w == src_img->w) && (roi.h == src_img->h) && (args[ARG_channel].u_int == -1) && - (args[ARG_alpha].u_int == 256) && + (args[ARG_alpha].u_int == 255) && (color_palette == NULL) && (alpha_palette == NULL) && (!transposed); @@ -1732,7 +1732,7 @@ static mp_obj_t py_image_line_op(uint n_args, const mp_obj_t *pos_args, mp_map_t { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -1788,8 +1788,8 @@ static mp_obj_t py_image_line_op(uint n_args, const mp_obj_t *pos_args, mp_map_t mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } float x_scale = 1.0f; @@ -2692,7 +2692,7 @@ static mp_obj_t py_image_get_similarity(uint n_args, const mp_obj_t *pos_args, m { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -2712,8 +2712,8 @@ static mp_obj_t py_image_get_similarity(uint n_args, const mp_obj_t *pos_args, m mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } float x_scale = 1.0f; diff --git a/src/omv/modules/py_mjpeg.c b/src/omv/modules/py_mjpeg.c index 284715ae9..00521a067 100644 --- a/src/omv/modules/py_mjpeg.c +++ b/src/omv/modules/py_mjpeg.c @@ -98,7 +98,7 @@ static mp_obj_t py_mjpeg_write(uint n_args, const mp_obj_t *pos_args, mp_map_t * static const mp_arg_t allowed_args[] = { { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -119,8 +119,8 @@ static mp_obj_t py_mjpeg_write(uint n_args, const mp_obj_t *pos_args, mp_map_t * mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } if (args[ARG_quality].u_int < 0 || args[ARG_quality].u_int > 100) { diff --git a/src/omv/modules/py_tof.c b/src/omv/modules/py_tof.c index a77c2c57e..723a88ffe 100644 --- a/src/omv/modules/py_tof.c +++ b/src/omv/modules/py_tof.c @@ -403,7 +403,7 @@ mp_obj_t py_tof_draw_depth(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_a { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_INT(COLOR_PALETTE_DEPTH)} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -423,8 +423,8 @@ mp_obj_t py_tof_draw_depth(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_a mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } image_t src_img = { @@ -479,7 +479,7 @@ mp_obj_t py_tof_snapshot(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_INT(COLOR_PALETTE_DEPTH)} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -498,8 +498,8 @@ mp_obj_t py_tof_snapshot(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } if ((args[ARG_pixformat].u_int != PIXFORMAT_GRAYSCALE) && (args[ARG_pixformat].u_int != PIXFORMAT_RGB565)) { diff --git a/src/omv/modules/py_tv.c b/src/omv/modules/py_tv.c index 411e1fefd..6d06120dc 100644 --- a/src/omv/modules/py_tv.c +++ b/src/omv/modules/py_tv.c @@ -895,7 +895,7 @@ static mp_obj_t py_tv_display(uint n_args, const mp_obj_t *pos_args, mp_map_t *k { MP_QSTR_y_scale, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_roi, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_rgb_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1 } }, - { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 256 } }, + { MP_QSTR_alpha, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 255 } }, { MP_QSTR_color_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_alpha_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_hint, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0 } }, @@ -912,8 +912,8 @@ static mp_obj_t py_tv_display(uint n_args, const mp_obj_t *pos_args, mp_map_t *k mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("RGB channel can be 0, 1, or 2")); } - if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 256) { - mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 256")); + if (args[ARG_alpha].u_int < 0 || args[ARG_alpha].u_int > 255) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Alpha ranges between 0 and 255")); } float x_scale = 1.0f; diff --git a/src/omv/ports/stm32/modules/py_display.c b/src/omv/ports/stm32/modules/py_display.c index 9ec97cb49..6e99556bd 100644 --- a/src/omv/ports/stm32/modules/py_display.c +++ b/src/omv/ports/stm32/modules/py_display.c @@ -442,7 +442,7 @@ static void display_write(py_display_obj_t *self, image_t *src_img, int dst_x_st display.framebuffer_layers[tail].WindowX1 = black ? self->width : p1.x; display.framebuffer_layers[tail].WindowY0 = black ? 0 : p0.y; display.framebuffer_layers[tail].WindowY1 = black ? self->height : p1.y; - display.framebuffer_layers[tail].Alpha = black ? 0 : fast_roundf((alpha * 255) / 256.f); + display.framebuffer_layers[tail].Alpha = black ? 0 : alpha; display.framebuffer_layers[tail].FBStartAdress = black ? ((uint32_t) dst_img.data) : ((uint32_t) (IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(&dst_img, p0.y) + p0.x)); display.framebuffer_layers[tail].ImageWidth = black ? self->width : dst_img.w; @@ -451,7 +451,7 @@ static void display_write(py_display_obj_t *self, image_t *src_img, int dst_x_st // Set alpha to 256 here as we will use the layer alpha to blend the image into the background color of black for free. if (!black) { imlib_draw_image(&dst_img, src_img, dst_x_start, dst_y_start, - x_scale, y_scale, roi, rgb_channel, 256, color_palette, + x_scale, y_scale, roi, rgb_channel, 255, color_palette, alpha_palette, hint | IMAGE_HINT_BLACK_BACKGROUND, NULL, NULL, NULL); } diff --git a/src/omv/ports/stm32/omv_gpu.c b/src/omv/ports/stm32/omv_gpu.c index 4adfa1173..42c2fa6f9 100644 --- a/src/omv/ports/stm32/omv_gpu.c +++ b/src/omv/ports/stm32/omv_gpu.c @@ -87,7 +87,7 @@ int omv_gpu_draw_image(image_t *src_img, dma2d.Init.Mode = DMA2D_M2M_PFC; } - if ((alpha != 256) || alpha_palette) { + if ((alpha != 255) || alpha_palette) { dma2d.Init.Mode = DMA2D_M2M_BLEND; } @@ -159,7 +159,7 @@ int omv_gpu_draw_image(image_t *src_img, } dma2d.LayerCfg[1].InputOffset = src_img->w - src_rect->w; - dma2d.LayerCfg[1].InputAlpha = (alpha * 255) / 256; + dma2d.LayerCfg[1].InputAlpha = alpha; HAL_DMA2D_ConfigLayer(&dma2d, 1);