@@ -144,18 +144,23 @@ def boundingRect(self) -> QtCore.QRectF:
144
144
return QtCore .QRectF (0. , 0. , 0. , 0. )
145
145
return QtCore .QRectF (0. , 0. , float (self .width ()), float (self .height ()))
146
146
147
- def setLevels (self , levels : npt .ArrayLike , update : bool = True ):
147
+ def setLevels (self , levels : npt .ArrayLike | None , update : bool = True ):
148
148
"""
149
- Sets image scaling levels.
149
+ Sets image scaling levels. Calling this method, even with ``levels=None`` will
150
+ disable auto leveling (set ``autoLevels=False``).
150
151
151
152
Parameters
152
153
----------
153
- levels : array_like
154
+ levels : array_like or None
154
155
- ``[blackLevel, whiteLevel]``
155
156
sets black and white levels for monochrome data and can be used with a
156
157
lookup table.
157
158
- ``[[minR, maxR], [minG, maxG], [minB, maxB]]``
158
159
sets individual scaling for RGB values. Not compatible with lookup tables.
160
+ - ``None``
161
+ Disables the application of levels, but setting to ``None`` prevents
162
+ the auto-levels mechanism from sampling the image. Not compatible with
163
+ images that use floating point dtypes.
159
164
update : bool, optional
160
165
Controls if image immediately updates to reflect the new levels, default True
161
166
@@ -173,10 +178,11 @@ def setLevels(self, levels: npt.ArrayLike, update: bool=True):
173
178
if update :
174
179
self .updateImage ()
175
180
176
- def getLevels (self ):
181
+ def getLevels (self ) -> numpy . ndarray | None :
177
182
"""
178
- Returns the list representing the current level settings. See :func:`setLevels`.
179
- When ``autoLevels`` is active, the format is ``[blackLevel, whiteLevel]``.
183
+ Returns the array representing the current level settings. See
184
+ :func:`setLevels`. When ``autoLevels`` is active, the format is
185
+ ``[blackLevel, whiteLevel]``.
180
186
"""
181
187
return self .levels
182
188
@@ -503,7 +509,7 @@ def setImage(
503
509
if mn == mx or self ._xp .isnan (mn ) or self ._xp .isnan (mx ):
504
510
mn = 0
505
511
mx = 255
506
- kargs ['levels' ] = [ mn ,mx ]
512
+ kargs ['levels' ] = self . _xp . asarray (( mn ,mx ))
507
513
508
514
profile ()
509
515
0 commit comments