fsleyes_widgets.utils.textbitmap¶
This module provides a single function, textBitmap(), which renders
some text off-screen using matplotlib, and returns it as an RGBA bitmap.
-
fsleyes_widgets.utils.textbitmap.textBitmap(text, width=None, height=None, fontSize=None, fgColour=None, bgColour=None, alpha=1.0, fontFamily=None, dpi=96)[source]¶ Draw some text using
matplotlib.The rendered text is returned as a RGBA bitmap within a
numpy.uint8array of size \(h \times w \times 4\), with the top-left pixel located at index[0, 0, :].At least one of the
fontSizeor theheightarguments need to be specified - if one of these is provided, the other size options will be inferred, although the inference procedure does not support multi-line text.- Parameters
text – Text to render.
width – Width in pixels.
height – Height in pixels.
fontSize – Font size in points.
fgColour – Foreground (text) colour - can be any colour specification that is accepted by
matplotlib.bgColour – Background colour - can be any colour specification that is accepted by
matplotlib..alpha – Text transparency, in the range
[0.0 - 1.0].fontFamily – Font family, e.g.
'monospace'or'sans-serif', defaults to matplotlib default.dpi – Dots per inch, defaults to 96.
- Returns
numpy.uint8array of size \(h \times w \times 4\)