Skip to content

Commit 3525821

Browse files
committed
Correct y= argument of JpegDecoder.decode
.. update the tests as well. Don't dump the bitmap when the bitmaps already compared equal for the crop and position tests.
1 parent 1d13364 commit 3525821

File tree

3 files changed

+8
-166
lines changed

3 files changed

+8
-166
lines changed

shared-bindings/jpegio/JpegDecoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ STATIC mp_obj_t jpegio_jpegdecoder_decode(mp_uint_t n_args, const mp_obj_t *pos_
176176
mp_arg_validate_int_range(scale, 0, 3, MP_QSTR_scale);
177177

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

182182
uint32_t skip_source_index;

tests/circuitpython/jpegio_decompress.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def test(jpeg_input, scale, fill=0xFFFF, **position_and_crop):
7777

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

80-
dump_bitmap(b)
81-
8280
if position_and_crop:
8381
position_and_crop.setdefault("x", 0)
8482
position_and_crop.setdefault("y", 0)
@@ -89,6 +87,10 @@ def test(jpeg_input, scale, fill=0xFFFF, **position_and_crop):
8987
refb.fill(fill)
9088
bitmaptools.blit(refb, full, **position_and_crop)
9189
print(f"{memoryview(refb) == memoryview(b)=}")
90+
if not memoryview(refb) == memoryview(b):
91+
dump_bitmap(b)
92+
else:
93+
dump_bitmap(b)
9294

9395

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

123125
print("crop & move")
124-
test(content, scale=3, x=8, y=8)
125-
test(content, scale=3, x1=8, y1=8)
126+
test(content, scale=3, x=8, y=12)
127+
test(content, scale=3, x1=8, y1=12)
126128
test(content, scale=3, x2=16, y2=16)
127-
test(content, scale=3, x=12, y=12, x1=8, y1=12, x2=16, y2=16)
129+
test(content, scale=3, x=12, y=16, x1=8, y1=12, x2=16, y2=16)
128130

129131
print("color key")
130132
test(content, scale=0, skip_source_index=0x4529, fill=0)

tests/circuitpython/jpegio_decompress.py.exp

Lines changed: 0 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -201,173 +201,13 @@ IOAdapter
201201

202202
crop & move
203203
30x30
204-
205-
206-
207-
208-
209-
210-
211-
212-
213-
###
214-
## ##
215-
#### ###
216-
#### ## #
217-
#### ## #
218-
## #### #
219-
#### ######
220-
#####
221-
####
222-
####
223-
###
224-
## # #
225-
### #
226-
# ####
227-
###
228-
## ## ## ## #
229-
# # ## #####
230-
# ##### #### ##
231-
# # ## ## ###
232-
# #### ####
233-
## ##### #######
234-
...
235-
236204
memoryview(refb) == memoryview(b)=True
237205
30x30
238-
#####
239-
####
240-
####
241-
###
242-
## # #
243-
### #
244-
# ####
245-
###
246-
## ## ## ## #
247-
# ## #####
248-
##### #### ## ##
249-
# ## ## ### ###
250-
#### ##### ##
251-
#### ####### # #
252-
## ######## ####
253-
#### ######
254-
## ##############
255-
##### ########## # #
256-
###### ### ## ####
257-
# ### ##### ##
258-
## ##
259-
260-
261-
262-
263-
264-
265-
266-
267-
268-
...
269-
270206
memoryview(refb) == memoryview(b)=True
271207
30x30
272-
273-
###
274-
## ##
275-
#### ##
276-
#### ##
277-
#### ##
278-
## ####
279-
#### ####
280-
####
281-
####
282-
####
283-
###
284-
## # #
285-
### #
286-
# ####
287-
###
288-
289-
290-
291-
292-
293-
294-
295-
296-
297-
298-
299-
300-
301-
302-
...
303-
304208
memoryview(refb) == memoryview(b)=True
305209
30x30
306-
307-
308-
309-
310-
311-
312-
313-
314-
315-
316-
317-
318-
## # #
319-
### #
320-
# ####
321-
###
322-
323-
324-
325-
326-
327-
328-
329-
330-
331-
332-
333-
334-
335-
336-
...
337-
338210
memoryview(refb) == memoryview(b)=True
339211
color key
340212
240x240
341-
########################################################################...
342-
########################################################################...
343-
########################################################################...
344-
########################################################################...
345-
########################################################################...
346-
########################################################################...
347-
########################################################################...
348-
########################################################################...
349-
########################################################################...
350-
########################################################################...
351-
########################################################################...
352-
########################################################################...
353-
########################################################################...
354-
########################################################################...
355-
########################################################################...
356-
########################################################################...
357-
################################################################ ...
358-
################################################################ ...
359-
################################################################ ...
360-
################################################################ ...
361-
###################################################################### ...
362-
###################################################################### ...
363-
###################################################################### ...
364-
###################################################################### ...
365-
################################################### # ###### ...
366-
################################################ ## ### ###### ...
367-
################################################ #### ## ...
368-
################################################ ## ##...
369-
################################################ ## ###### ...
370-
################################################ # # ### #...
371-
...
372-
373213
memoryview(refb) == memoryview(b)=True

0 commit comments

Comments
 (0)