@@ -9407,9 +9407,13 @@ def __init__(self, *args):
9407
9407
pm = mupdf.fz_new_pixmap_with_bbox(cs, JM_irect_from_py(rect), mupdf.FzSeparations(0), alpha)
9408
9408
self.this = pm
9409
9409
9410
- elif args_match(args, mupdf.FzColorspace, mupdf.FzPixmap):
9410
+ elif args_match(args, (Colorspace, mupdf.FzColorspace), (Pixmap, mupdf.FzPixmap) ):
9411
9411
# copy pixmap, converting colorspace
9412
9412
cs, spix = args
9413
+ if isinstance(cs, Colorspace):
9414
+ cs = cs.this
9415
+ if isinstance(spix, Pixmap):
9416
+ spix = spix.this
9413
9417
if not mupdf.fz_pixmap_colorspace(spix).m_internal:
9414
9418
raise ValueError( "source colorspace must not be None")
9415
9419
@@ -9427,9 +9431,13 @@ def __init__(self, *args):
9427
9431
if not self.this.m_internal:
9428
9432
raise RuntimeError( MSG_PIX_NOALPHA)
9429
9433
9430
- elif args_match(args, mupdf.FzPixmap, mupdf.FzPixmap):
9434
+ elif args_match(args, (Pixmap, mupdf.FzPixmap), (Pixmap, mupdf.FzPixmap) ):
9431
9435
# add mask to a pixmap w/o alpha channel
9432
9436
spix, mpix = args
9437
+ if isinstance(spix, Pixmap):
9438
+ spix = spix.this
9439
+ if isinstance(mpix, Pixmap):
9440
+ mpix = mpix.this
9433
9441
spm = spix
9434
9442
mpm = mpix
9435
9443
if not spix.m_internal: # intercept NULL for spix: make alpha only pix
@@ -9438,7 +9446,7 @@ def __init__(self, *args):
9438
9446
raise RuntimeError( MSG_PIX_NOALPHA)
9439
9447
else:
9440
9448
dst = mupdf.fz_new_pixmap_from_color_and_mask( spm, mpm)
9441
- return dst
9449
+ self.this = dst
9442
9450
9443
9451
elif args_match(args, (Pixmap, mupdf.FzPixmap), (float, int), (float, int), None):
9444
9452
# create pixmap as scaled copy of another one
@@ -9453,9 +9461,11 @@ def __init__(self, *args):
9453
9461
pm = mupdf.fz_scale_pixmap(src_pix, src_pix.x(), src_pix.y(), w, h, mupdf.FzIrect(mupdf.fz_infinite_irect))
9454
9462
self.this = pm
9455
9463
9456
- elif args_match(args, str, mupdf.FzPixmap) and args[0] == 'raw':
9464
+ elif args_match(args, str, (Pixmap, mupdf.FzPixmap) ) and args[0] == 'raw':
9457
9465
# Special raw construction where we set .this directly.
9458
9466
_, pm = args
9467
+ if isinstance(pm, Pixmap):
9468
+ pm = pm.this
9459
9469
self.this = pm
9460
9470
9461
9471
elif args_match(args, (Pixmap, mupdf.FzPixmap), (int, None)):
@@ -10190,7 +10200,7 @@ def y(self):
10190
10200
@property
10191
10201
def yres(self):
10192
10202
"""Resolution in y direction."""
10193
- return mupdf.fz_pixmap_width( self.this)
10203
+ return self.this.yres( )
10194
10204
10195
10205
width = w
10196
10206
height = h
0 commit comments