diff --git a/NEWS.md b/NEWS.md index 90cb2f975..e6861c9bf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,7 +8,7 @@ rearrangements of Notcurses. * Added `NCOPTION_CLI_MODE`, an alias for the bitwise OR of `NCOPTION_SCROLLING`, `NCOPTION_NO_CLEAR_BITMAPS`, `NCOPTION_NO_ALTERNATE_SCREEN`, and `NCOPTION_PRESERVE_CURSOR`. - * Added `ncsixel_as_rgba()`. + * Added `ncvisual_from_sixel()`. * 3.0.1 (2021-12-14) * Added the `NCPLANE_OPTION_VSCROLL` flag. Creating an `ncplane` with this diff --git a/src/lib/sixel.h b/src/lib/sixel.h index 9c507cc69..a7fba923f 100644 --- a/src/lib/sixel.h +++ b/src/lib/sixel.h @@ -11,12 +11,12 @@ extern "C" { uint32_t* ncsixel_as_rgba(const char *sx, unsigned leny, unsigned lenx){ #define MAXCOLORS 65535 // cast is necessary for c++ callers - uint32_t* rgba = (typeof rgba)malloc(sizeof(*rgba) * leny * lenx); + uint32_t* rgba = (uint32_t*)malloc(sizeof(*rgba) * leny * lenx); if(rgba == NULL){ return NULL; } // cast is necessary for c++ callers - uint32_t* colors = (typeof colors)malloc(sizeof(*colors) * MAXCOLORS); + uint32_t* colors = (uint32_t*)malloc(sizeof(*colors) * MAXCOLORS); if(colors == NULL){ free(rgba); return NULL; diff --git a/src/lib/visual.c b/src/lib/visual.c index 23a6d89aa..87858e4e2 100644 --- a/src/lib/visual.c +++ b/src/lib/visual.c @@ -3,6 +3,7 @@ #include "builddef.h" #include "visual-details.h" #include "internal.h" +#include "sixel.h" // ncvisual core code has a basic implementation in libnotcurses-core, and can // be augmented with a "multimedia engine" -- currently FFmpeg or OpenImageIO, @@ -796,6 +797,17 @@ ncvisual* ncvisual_from_rgba(const void* rgba, int rows, int rowstride, int cols return ncv; } +ncvisual* ncvisual_from_sixel(const char* s, unsigned leny, unsigned lenx){ + uint32_t* rgba = ncsixel_as_rgba(s, leny, lenx); + if(rgba == NULL){ + logerror("failed converting sixel to rgba"); + return NULL; + } + ncvisual* ncv = ncvisual_from_rgba(rgba, leny, lenx * sizeof(*rgba), lenx); + free(rgba); + return ncv; +} + ncvisual* ncvisual_from_rgb_packed(const void* rgba, int rows, int rowstride, int cols, int alpha){ ncvisual* ncv = ncvisual_create(); diff --git a/src/media/oiio.cpp b/src/media/oiio.cpp index 80879def2..e2a68b881 100644 --- a/src/media/oiio.cpp +++ b/src/media/oiio.cpp @@ -144,7 +144,7 @@ int oiio_resize(ncvisual* nc, unsigned rows, unsigned cols) { return 0; } -int oiio_blit(struct ncvisual* ncv, unsigned rows, unsigned cols, +int oiio_blit(const ncvisual* ncv, unsigned rows, unsigned cols, ncplane* n, const struct blitset* bset, const blitterargs* bargs) { //fprintf(stderr, "%d/%d -> %d/%d on the resize\n", ncv->pixy, ncv->pixx, rows, cols);