Skip to content

Correct y= argument of JpegDecoder.decode #8784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared-bindings/jpegio/JpegDecoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ STATIC mp_obj_t jpegio_jpegdecoder_decode(mp_uint_t n_args, const mp_obj_t *pos_
mp_arg_validate_int_range(scale, 0, 3, MP_QSTR_scale);

int x = mp_arg_validate_int_range(args[ARG_x].u_int, 0, bitmap->width, MP_QSTR_x);
int y = mp_arg_validate_int_range(args[ARG_x].u_int, 0, bitmap->height, MP_QSTR_y);
int y = mp_arg_validate_int_range(args[ARG_y].u_int, 0, bitmap->height, MP_QSTR_y);
bitmaptools_rect_t lim = bitmaptools_validate_coord_range_pair(&args[ARG_x1], bitmap->width, bitmap->height);

uint32_t skip_source_index;
Expand Down
12 changes: 7 additions & 5 deletions tests/circuitpython/jpegio_decompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def test(jpeg_input, scale, fill=0xFFFF, **position_and_crop):

decoder.decode(b, scale=scale, **position_and_crop)

dump_bitmap(b)

if position_and_crop:
position_and_crop.setdefault("x", 0)
position_and_crop.setdefault("y", 0)
Expand All @@ -89,6 +87,10 @@ def test(jpeg_input, scale, fill=0xFFFF, **position_and_crop):
refb.fill(fill)
bitmaptools.blit(refb, full, **position_and_crop)
print(f"{memoryview(refb) == memoryview(b)=}")
if not memoryview(refb) == memoryview(b):
dump_bitmap(b)
else:
dump_bitmap(b)


class IOAdapter(io.IOBase):
Expand Down Expand Up @@ -121,10 +123,10 @@ def readinto(self, buf):
test(io.BytesIO(content), scale=3)

print("crop & move")
test(content, scale=3, x=8, y=8)
test(content, scale=3, x1=8, y1=8)
test(content, scale=3, x=8, y=12)
test(content, scale=3, x1=8, y1=12)
test(content, scale=3, x2=16, y2=16)
test(content, scale=3, x=12, y=12, x1=8, y1=12, x2=16, y2=16)
test(content, scale=3, x=12, y=16, x1=8, y1=12, x2=16, y2=16)

print("color key")
test(content, scale=0, skip_source_index=0x4529, fill=0)
160 changes: 0 additions & 160 deletions tests/circuitpython/jpegio_decompress.py.exp
Original file line number Diff line number Diff line change
Expand Up @@ -201,173 +201,13 @@ IOAdapter

crop & move
30x30









###
## ##
#### ###
#### ## #
#### ## #
## #### #
#### ######
#####
####
####
###
## # #
### #
# ####
###
## ## ## ## #
# # ## #####
# ##### #### ##
# # ## ## ###
# #### ####
## ##### #######
...

memoryview(refb) == memoryview(b)=True
30x30
#####
####
####
###
## # #
### #
# ####
###
## ## ## ## #
# ## #####
##### #### ## ##
# ## ## ### ###
#### ##### ##
#### ####### # #
## ######## ####
#### ######
## ##############
##### ########## # #
###### ### ## ####
# ### ##### ##
## ##









...

memoryview(refb) == memoryview(b)=True
30x30

###
## ##
#### ##
#### ##
#### ##
## ####
#### ####
####
####
####
###
## # #
### #
# ####
###














...

memoryview(refb) == memoryview(b)=True
30x30












## # #
### #
# ####
###














...

memoryview(refb) == memoryview(b)=True
color key
240x240
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
########################################################################...
################################################################ ...
################################################################ ...
################################################################ ...
################################################################ ...
###################################################################### ...
###################################################################### ...
###################################################################### ...
###################################################################### ...
################################################### # ###### ...
################################################ ## ### ###### ...
################################################ #### ## ...
################################################ ## ##...
################################################ ## ###### ...
################################################ # # ### #...
...

memoryview(refb) == memoryview(b)=True