Skip to content

Commit 4a09827

Browse files
committed
Review & update bitmapfilter documentation
1 parent 6d30ff5 commit 4a09827

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

shared-bindings/bitmapfilter/__init__.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ static mp_float_t float_subscr(mp_obj_t o, int i) {
171171
//| If ``weights`` is a list of length 12, then channels are mixed with an offset.
172172
//| Every fourth value is the offset value.
173173
//|
174+
//| ``mask`` is another image to use as a pixel level mask for the operation.
175+
//| The mask should be an image the same size as the image being operated on.
176+
//| Only pixels set to a non-zero value in the mask are modified.
177+
//|
174178
//| For example, to perform a sepia conversion on an input image,
175179
//|
176180
//| .. code-block:: python
@@ -277,8 +281,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_solarize_obj, 0, bitmapfilter_solarize);
277281
//| def lookup(
278282
//| bitmap: displayio.Bitmap,
279283
//| lookup: LookupFunction | ThreeLookupFunctions,
280-
//| lookup_g: LookupFunction,
281-
//| lookup_b: LookupFunction,
282284
//| mask: displayio.Bitmap | None,
283285
//| ) -> displayio.Bitmap:
284286
//| """Modify the channels of a bitmap according to a look-up table
@@ -287,11 +289,19 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_solarize_obj, 0, bitmapfilter_solarize);
287289
//| such as gamma curves.
288290
//|
289291
//| The ``bitmap``, which must be in RGB565_SWAPPED format, is modified
290-
//| according to the values in the ``table``s.
292+
//| according to the values of the ``lookup`` function or functions.
293+
//|
294+
//| If one ``lookup`` function is supplied, the same function is used for all 3
295+
//| image channels. Otherwise, it must be a tuple of 3 functions. The first
296+
//| function is used for R, the second function for G, and the third for B.
291297
//|
292298
//| Each lookup function is called for each possible channel value from 0 to 1
293299
//| inclusive (64 times for green, 32 times for red or blue), and the return
294300
//| value (also from 0 to 1) is used whenever that color value is returned.
301+
//|
302+
//| ``mask`` is another image to use as a pixel level mask for the operation.
303+
//| The mask should be an image the same size as the image being operated on.
304+
//| Only pixels set to a non-zero value in the mask are modified.
295305
//| """
296306
//|
297307

@@ -355,11 +365,17 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_lookup_obj, 0, bitmapfilter_lookup);
355365
//| ) -> displayio.Bitmap:
356366
//| """Convert the image to false color using the given palette
357367
//|
358-
//| The ``bitmap``, which must be in RGB565_SWAPPED format, is converted into false color:
368+
//| The ``bitmap``, which must be in RGB565_SWAPPED format, is converted into false color.
369+
//|
370+
//| The ``palette``, which must be of length 256, is used as a look-up table.
359371
//|
360372
//| Each pixel is converted to a luminance (brightness/greyscale) value
361373
//| in the range 0..255, then the corresponding palette entry is looked up and
362374
//| stored in the bitmap.
375+
//|
376+
//| ``mask`` is another image to use as a pixel level mask for the operation.
377+
//| The mask should be an image the same size as the image being operated on.
378+
//| Only pixels set to a non-zero value in the mask are modified.
363379
//| """
364380
//|
365381
STATIC mp_obj_t bitmapfilter_false_color(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {

0 commit comments

Comments
 (0)