2020-01-02 02:23:11 +00:00
|
|
|
|
% notcurses_ncvisual(3)
|
|
|
|
|
% nick black <nickblack@linux.com>
|
2020-04-27 01:25:23 +00:00
|
|
|
|
% v1.3.3
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
|
|
# NAME
|
2020-01-04 07:37:55 +00:00
|
|
|
|
notcurses_ncvisual - notcurses multimedia
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
|
|
# SYNOPSIS
|
|
|
|
|
|
2020-04-19 22:46:32 +00:00
|
|
|
|
**#include <notcurses/notcurses.h>**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
2020-01-04 07:37:55 +00:00
|
|
|
|
```c
|
|
|
|
|
typedef enum {
|
|
|
|
|
NCSCALE_NONE,
|
|
|
|
|
NCSCALE_SCALE,
|
|
|
|
|
NCSCALE_STRETCH,
|
|
|
|
|
} ncscale_e;
|
2020-01-14 20:50:17 +00:00
|
|
|
|
|
|
|
|
|
typedef int (*streamcb)(struct notcurses*, struct ncvisual*, void*);
|
2020-01-04 07:37:55 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-01-17 14:30:53 +00:00
|
|
|
|
**bool notcurses_canopen(const struct notcurses* nc);**
|
|
|
|
|
|
|
|
|
|
**struct ncvisual* ncplane_visual_open(struct ncplane* nc, const char* file,
|
2020-04-24 05:25:46 +00:00
|
|
|
|
nc_err_e* err);**
|
2020-01-17 14:30:53 +00:00
|
|
|
|
|
2020-05-04 08:55:10 +00:00
|
|
|
|
**struct ncvisual* ncvisual_from_file(struct notcurses* nc, const char* file,
|
2020-04-24 05:25:46 +00:00
|
|
|
|
nc_err_e* err, int y, int x,
|
2020-01-04 07:37:55 +00:00
|
|
|
|
ncscale_e style);**
|
|
|
|
|
|
2020-05-04 08:55:10 +00:00
|
|
|
|
**struct ncvisual* ncvisual_from_rgba(struct notcurses* nc, const void* rgba, int rows, int rowstride, int cols);**
|
|
|
|
|
|
|
|
|
|
**struct ncvisual* ncvisual_from_bgra(struct notcurses* nc, const void* bgra, int rows, int rowstride, int cols);**
|
|
|
|
|
|
2020-01-04 07:37:55 +00:00
|
|
|
|
**void ncvisual_destroy(struct ncvisual* ncv);**
|
|
|
|
|
|
2020-04-24 07:17:34 +00:00
|
|
|
|
**nc_err_e ncvisual_decode(struct ncvisual* nc);**
|
2020-01-04 07:37:55 +00:00
|
|
|
|
|
|
|
|
|
**int ncvisual_render(const struct ncvisual* ncv, int begy, int begx,
|
|
|
|
|
int leny, int lenx);**
|
|
|
|
|
|
|
|
|
|
**int ncvisual_simple_streamer(struct notcurses* nc, struct ncvisual* ncv, void* curry);**
|
|
|
|
|
|
2020-04-24 05:25:46 +00:00
|
|
|
|
**int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv, nc_err_e* err,
|
2020-01-14 20:50:17 +00:00
|
|
|
|
float timescale, streamcb streamer, void* curry);**
|
2020-01-04 07:37:55 +00:00
|
|
|
|
|
|
|
|
|
**struct ncplane* ncvisual_plane(struct ncvisual* ncv);**
|
|
|
|
|
|
2020-05-06 09:49:22 +00:00
|
|
|
|
**int ncvisual_rotate(struct ncvisual* n, double rads);**
|
2020-05-04 04:51:42 +00:00
|
|
|
|
|
2020-05-04 04:56:52 +00:00
|
|
|
|
**char* ncvisual_subtitle(const struct ncvisual* ncv);**
|
2020-05-04 04:51:42 +00:00
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
|
# DESCRIPTION
|
|
|
|
|
|
2020-03-24 22:43:10 +00:00
|
|
|
|
The frame will be scaled to the size of the ncplane per the ncscale_e style.
|
|
|
|
|
**ncvisual_render** actually blits the decoded frame to its associated plane.
|
|
|
|
|
A subregion of the frame can be specified using **begx**, **begy**, **lenx**,
|
|
|
|
|
and **leny**. To render the rectangle having its origin at **begy**, **begx**
|
|
|
|
|
and the lower-right corner, -1 can be supplied as **leny** and **lenx**.
|
|
|
|
|
{0, 0, -1, -1} will thus render the entire visual. Negative values for **begy**
|
|
|
|
|
or **begx** are an error. It is an error to specify any region beyond the
|
|
|
|
|
boundaries of the frame. Supplying zero for either **leny** or **lenx** will
|
|
|
|
|
result in a zero-area rendering.
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
2020-05-04 08:55:10 +00:00
|
|
|
|
It is possible to create an **ncvisual** from memory, rather than from a
|
|
|
|
|
disk, but only using raw RGBA/BGRA 8bpc content. For RGBA, use
|
|
|
|
|
**ncvisual_from_rgba**. For BGRA, use **ncvisual_from_bgra**. Both require
|
|
|
|
|
a number of **rows**, a number of image columns **cols**, and a virtual row
|
2020-05-04 15:05:52 +00:00
|
|
|
|
length of **rowstride** / 4 columns. The input data must provide 32 bits per
|
|
|
|
|
pixel, and thus must be at least **rowstride** * **rows** bytes, of
|
2020-05-04 08:55:10 +00:00
|
|
|
|
which a **cols** * **rows** * 4-byte subset is used. It is not possible to
|
|
|
|
|
**mmap(2)** an image file and use it directly--decompressed, decoded data
|
2020-05-04 15:05:52 +00:00
|
|
|
|
is necessary. The resulting plane will be ceil(**rows**/2) rows, and **cols**
|
2020-05-04 08:55:10 +00:00
|
|
|
|
columns. It will not be necessary to call **ncvisual_decode**, but it is
|
|
|
|
|
still necessary to call **ncvisual_render**.
|
|
|
|
|
|
2020-05-06 09:49:22 +00:00
|
|
|
|
**ncvisual_rotate** executes a rotation of **rads** radians, in the clockwise
|
|
|
|
|
(positive) or counterclockwise (negative) direction. If the **ncvisual** owns
|
|
|
|
|
(created) its underlying **ncplane**, that plane will be resized as necessary
|
|
|
|
|
to display the entirety of the rotated visual.
|
2020-05-04 04:51:42 +00:00
|
|
|
|
|
2020-05-04 04:56:52 +00:00
|
|
|
|
**ncvisual_subtitle** will return a UTF-8-encoded subtitle corresponding to
|
|
|
|
|
the current frame if such a subtitle was decoded. Note that a subtitle might
|
|
|
|
|
be returned for multiple frames, or might not.
|
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
|
# RETURN VALUES
|
|
|
|
|
|
2020-03-24 22:43:10 +00:00
|
|
|
|
**notcurses_canopen** returns true if this functionality is enabled, or false
|
2020-04-25 19:52:23 +00:00
|
|
|
|
if Notcurses was not built with multimedia support. **ncplane_visual_open** and
|
2020-05-04 08:55:10 +00:00
|
|
|
|
**ncvisual_from_file** return an **ncvisual** object on success, or **NULL**
|
2020-03-24 22:43:10 +00:00
|
|
|
|
on failure. Success from these functions indicates that the specified **file**
|
|
|
|
|
was opened, and enough data was read to make a firm codec identification. It
|
2020-04-24 05:25:46 +00:00
|
|
|
|
does not mean that the entire file is properly-formed. On failure, **err**
|
2020-04-24 07:17:34 +00:00
|
|
|
|
will be updated. **ncvisual_decode** returns **NCERR_SUCCESS** on success, or
|
|
|
|
|
**NCERR_EOF** on end of file, or some other **nc_err_e** on failure. It
|
|
|
|
|
likewise updates **err** in the event of an error. **ncvisual_render** returns
|
|
|
|
|
the number of cells emitted, or -1 on error.
|
|
|
|
|
|
|
|
|
|
# NOTES
|
|
|
|
|
|
|
|
|
|
Multimedia decoding requires that Notcurses be built with either FFmpeg or
|
|
|
|
|
OpenImageIO support. What formats can be decoded is totally dependent on the
|
2020-05-04 04:56:52 +00:00
|
|
|
|
linked library. OpenImageIO does not support subtitles.
|
2020-03-24 22:43:10 +00:00
|
|
|
|
|
2020-05-06 09:49:22 +00:00
|
|
|
|
# BUGS
|
|
|
|
|
|
|
|
|
|
**ncvisual_rotate** currently supports only **M_PI**/2 and -**M_PI**/2
|
|
|
|
|
radians for **rads**, but this will change soon.
|
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
|
# SEE ALSO
|
|
|
|
|
|
2020-05-04 04:56:52 +00:00
|
|
|
|
**notcurses(3)**,
|
|
|
|
|
**notcurses_ncplane(3)**,
|
|
|
|
|
**utf-8(7)**
|