mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
[ncplayer] direct mode support for chromakey #1515
This commit is contained in:
parent
feab25bd7d
commit
d4e2598c9e
@ -487,7 +487,8 @@ int ncdirect_raster_frame(ncdirect* n, ncdirectv* ncdv, ncalign_e align){
|
||||
|
||||
static ncdirectv*
|
||||
ncdirect_render_visual(ncdirect* n, ncvisual* ncv, ncblitter_e blitfxn,
|
||||
ncscale_e scale, int ymax, int xmax){
|
||||
ncscale_e scale, int ymax, int xmax,
|
||||
uint32_t transcolor){
|
||||
int dimy = ymax > 0 ? ymax : ncdirect_dim_y(n);
|
||||
int dimx = xmax > 0 ? xmax : ncdirect_dim_x(n);
|
||||
//fprintf(stderr, "OUR DATA: %p rows/cols: %d/%d\n", ncv->data, ncv->rows, ncv->cols);
|
||||
@ -539,6 +540,7 @@ ncdirect_render_visual(ncdirect* n, ncvisual* ncv, ncblitter_e blitfxn,
|
||||
return NULL;
|
||||
}
|
||||
blitterargs bargs = {};
|
||||
bargs.transcolor = transcolor;
|
||||
if(bset->geom == NCBLIT_PIXEL){
|
||||
bargs.u.pixel.celldimx = n->tcache.cellpixx;
|
||||
bargs.u.pixel.celldimy = n->tcache.cellpixy;
|
||||
@ -564,7 +566,7 @@ ncdirectv* ncdirect_render_frame(ncdirect* n, const char* file,
|
||||
if(ncv == NULL){
|
||||
return NULL;
|
||||
}
|
||||
ncdirectv* v = ncdirect_render_visual(n, ncv, blitfxn, scale, ymax, xmax);
|
||||
ncdirectv* v = ncdirect_render_visual(n, ncv, blitfxn, scale, ymax, xmax, 0);
|
||||
ncvisual_destroy(ncv);
|
||||
return v;
|
||||
}
|
||||
@ -1137,7 +1139,9 @@ int ncdirect_stream(ncdirect* n, const char* filename, ncstreamcb streamer,
|
||||
if(x > 0){
|
||||
ncdirect_cursor_left(n, x);
|
||||
}
|
||||
ncdirectv* v = ncdirect_render_visual(n, ncv, vopts->blitter, vopts->scaling, 0, 0);
|
||||
ncdirectv* v = ncdirect_render_visual(n, ncv, vopts->blitter, vopts->scaling,
|
||||
0, 0, (vopts->flags & NCVISUAL_OPTION_ADDALPHA) ?
|
||||
vopts->transcolor | 0x1000000ul : 0);
|
||||
if(v == NULL){
|
||||
ncvisual_destroy(ncv);
|
||||
return -1;
|
||||
|
@ -592,25 +592,25 @@ typedef struct notcurses {
|
||||
} notcurses;
|
||||
|
||||
typedef struct {
|
||||
int begy; // upper left start within visual
|
||||
int begy; // upper left start within visual
|
||||
int begx;
|
||||
int placey; // placement within ncplane
|
||||
int placey; // placement within ncplane
|
||||
int placex;
|
||||
uint32_t transcolor; // if non-zero, treat the lower 24 bits as a transparent color
|
||||
uint32_t transcolor; // if non-zero, treat the lower 24 bits as a transparent color
|
||||
union { // cell vs pixel-specific arguments
|
||||
struct {
|
||||
int blendcolors; // use CELL_ALPHA_BLEND
|
||||
} cell; // for cells
|
||||
int blendcolors; // use CELL_ALPHA_BLEND
|
||||
} cell; // for cells
|
||||
struct {
|
||||
int celldimx; // horizontal pixels per cell
|
||||
int celldimy; // vertical pixels per cell
|
||||
int colorregs; // number of color registers
|
||||
sprixel* spx; // sprixel object
|
||||
int celldimx; // horizontal pixels per cell
|
||||
int celldimy; // vertical pixels per cell
|
||||
int colorregs; // number of color registers
|
||||
sprixel* spx; // sprixel object
|
||||
// in at least mlterm, emitting a sixel makes the cursor visible.
|
||||
// if the cursor is hidden, and sprixel_cursor_hack is set, this
|
||||
// is set to the civis capability.
|
||||
const char* cursor_hack;
|
||||
} pixel; // for pixels
|
||||
} pixel; // for pixels
|
||||
} u;
|
||||
} blitterargs;
|
||||
|
||||
|
@ -310,7 +310,8 @@ int perframe_direct(struct ncvisual* ncv, struct ncvisual_options* vopts,
|
||||
|
||||
// argc/argv ought already be reduced to only the media arguments
|
||||
int direct_mode_player(int argc, char** argv, ncscale_e scalemode,
|
||||
ncblitter_e blitter, int lmargin){
|
||||
ncblitter_e blitter, int lmargin,
|
||||
unsigned transcolor){
|
||||
Direct dm{};
|
||||
if(!dm.canopen_images()){
|
||||
std::cerr << "Notcurses was compiled without multimedia support\n";
|
||||
@ -340,6 +341,10 @@ int direct_mode_player(int argc, char** argv, ncscale_e scalemode,
|
||||
vopts.scaling = scalemode;
|
||||
vopts.x = static_cast<int>(a);
|
||||
vopts.flags = NCVISUAL_OPTION_HORALIGNED;
|
||||
if(transcolor){
|
||||
vopts.flags |= NCVISUAL_OPTION_ADDALPHA;
|
||||
}
|
||||
vopts.transcolor = transcolor & 0xffffffull;
|
||||
if(dm.streamfile(argv[i], perframe_direct, &vopts, NULL)){
|
||||
failed = true;
|
||||
}
|
||||
@ -504,7 +509,8 @@ auto main(int argc, char** argv) -> int {
|
||||
// if -k was provided, we now use direct mode rather than simply not using the
|
||||
// alternate screen, so that output is inline with the shell.
|
||||
if(ncopts.flags & NCOPTION_NO_ALTERNATE_SCREEN){
|
||||
r = direct_mode_player(argc - nonopt, argv + nonopt, scalemode, blitter, ncopts.margin_l);
|
||||
r = direct_mode_player(argc - nonopt, argv + nonopt, scalemode, blitter,
|
||||
ncopts.margin_l, transcolor);
|
||||
}else{
|
||||
r = rendered_mode_player(argc - nonopt, argv + nonopt, scalemode, blitter, ncopts,
|
||||
quiet, loop, timescale, displaytime, transcolor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user