mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
implement ncvisual_from_sixel()
This commit is contained in:
parent
3d0fbc4d8f
commit
aa7903b370
2
NEWS.md
2
NEWS.md
@ -8,7 +8,7 @@ rearrangements of Notcurses.
|
|||||||
* Added `NCOPTION_CLI_MODE`, an alias for the bitwise OR of
|
* Added `NCOPTION_CLI_MODE`, an alias for the bitwise OR of
|
||||||
`NCOPTION_SCROLLING`, `NCOPTION_NO_CLEAR_BITMAPS`,
|
`NCOPTION_SCROLLING`, `NCOPTION_NO_CLEAR_BITMAPS`,
|
||||||
`NCOPTION_NO_ALTERNATE_SCREEN`, and `NCOPTION_PRESERVE_CURSOR`.
|
`NCOPTION_NO_ALTERNATE_SCREEN`, and `NCOPTION_PRESERVE_CURSOR`.
|
||||||
* Added `ncsixel_as_rgba()`.
|
* Added `ncvisual_from_sixel()`.
|
||||||
|
|
||||||
* 3.0.1 (2021-12-14)
|
* 3.0.1 (2021-12-14)
|
||||||
* Added the `NCPLANE_OPTION_VSCROLL` flag. Creating an `ncplane` with this
|
* Added the `NCPLANE_OPTION_VSCROLL` flag. Creating an `ncplane` with this
|
||||||
|
@ -11,12 +11,12 @@ extern "C" {
|
|||||||
uint32_t* ncsixel_as_rgba(const char *sx, unsigned leny, unsigned lenx){
|
uint32_t* ncsixel_as_rgba(const char *sx, unsigned leny, unsigned lenx){
|
||||||
#define MAXCOLORS 65535
|
#define MAXCOLORS 65535
|
||||||
// cast is necessary for c++ callers
|
// 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){
|
if(rgba == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// cast is necessary for c++ callers
|
// 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){
|
if(colors == NULL){
|
||||||
free(rgba);
|
free(rgba);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "builddef.h"
|
#include "builddef.h"
|
||||||
#include "visual-details.h"
|
#include "visual-details.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include "sixel.h"
|
||||||
|
|
||||||
// ncvisual core code has a basic implementation in libnotcurses-core, and can
|
// ncvisual core code has a basic implementation in libnotcurses-core, and can
|
||||||
// be augmented with a "multimedia engine" -- currently FFmpeg or OpenImageIO,
|
// 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;
|
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,
|
ncvisual* ncvisual_from_rgb_packed(const void* rgba, int rows, int rowstride,
|
||||||
int cols, int alpha){
|
int cols, int alpha){
|
||||||
ncvisual* ncv = ncvisual_create();
|
ncvisual* ncv = ncvisual_create();
|
||||||
|
@ -144,7 +144,7 @@ int oiio_resize(ncvisual* nc, unsigned rows, unsigned cols) {
|
|||||||
return 0;
|
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,
|
ncplane* n, const struct blitset* bset,
|
||||||
const blitterargs* bargs) {
|
const blitterargs* bargs) {
|
||||||
//fprintf(stderr, "%d/%d -> %d/%d on the resize\n", ncv->pixy, ncv->pixx, rows, cols);
|
//fprintf(stderr, "%d/%d -> %d/%d on the resize\n", ncv->pixy, ncv->pixx, rows, cols);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user