Skip to content

Commit

Permalink
Merge pull request #8102 from dhalbert/OnDiskGif-width-and-doc
Browse files Browse the repository at this point in the history
Improve OnDiskGif doc; check image width
  • Loading branch information
dhalbert authored Jun 22, 2023
2 parents 0da6241 + 1f2a1a6 commit c7c5d60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions shared-bindings/gifio/OnDiskGif.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
//| `displayio` expects little-endian, so the example above uses `Colorspace.RGB565_SWAPPED`.
//|
//| :param file file: The name of the GIF file.
//|
//| If the image is too large it will be cropped at the bottom and right when displayed.
//|
//| **Limitations**: The image width is limited to 320 pixels at present. `ValueError`
//| will be raised if the image is too wide. The height
//| is not limited but images that are too large will cause a memory exception.
//| """
//| ...
STATIC mp_obj_t gifio_ondiskgif_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
Expand Down
9 changes: 8 additions & 1 deletion shared-module/gifio/OnDiskGif.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,14 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_

int result = GIF_init(&self->gif);
if (result != 1) {
mp_arg_error_invalid(MP_QSTR_file);
switch (self->gif.iError) {
case GIF_TOO_WIDE:
mp_raise_ValueError_varg(translate("%q must be <= %d"), MP_QSTR_width, MAX_WIDTH);
break;
default:
mp_arg_error_invalid(MP_QSTR_file);
break;
}
}

int bpp = 16;
Expand Down

0 comments on commit c7c5d60

Please sign in to comment.