Fixed not checking that image is grayscale image for custom palette. Made demo simpler.

This commit is contained in:
mattdawson 2020-04-23 21:58:37 +12:00
parent 91efa307e0
commit 30383d32b6
2 changed files with 7 additions and 6 deletions

View File

@ -21,13 +21,10 @@ while(True):
clock.tick()
img = sensor.snapshot()
small_img = img.mean_pooled(4, 4) # Makes a copy.
img_copy = img.copy()
img.to_rgb565()
x = (img.width()//2)-(small_img.width()//2)
y = (img.height()//2)-(small_img.height()//2)
img.draw_image(small_img, x, y, x_scale=2, y_scale=2, color_palette=palette)
img.draw_image(img_copy, 0, 0, color_palette=palette)
print(clock.fps())

View File

@ -1954,6 +1954,10 @@ STATIC mp_obj_t py_image_draw_image(uint n_args, const mp_obj_t *args, mp_map_t
}
}
if (color_palette) {
if (arg_other->bpp != IMAGE_BPP_GRAYSCALE) nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Can only specify color palette when passing a grayscale image!"));
}
imlib_draw_image(arg_img, arg_other, arg_cx, arg_cy, arg_x_scale, arg_y_scale, arg_alpha, arg_msk, color_palette);
return args[0];
}