Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncplane_as_rgba returns NULL after a blitting image with transparent background on a plane #2723

Open
Albrict opened this issue Aug 2, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Albrict
Copy link

Albrict commented Aug 2, 2023

Please include the following data:

  • export | egrep 'LANG|LC_CTYPE|TERM'

     declare -x COLORTERM="truecolor"
     declare -x GDM_LANG="en_US.UTF-8"
     declare -x LANG="en_US.UTF-8"
     declare -x TERM="alacritty" 
    
  • notcurses version (available from notcurses-demo i)
    notcurses-demo version 3.0.9

  • terminal name + version
    Alacritty, version: 0.11.0-4

Issue

If you blit PNG image with transparent background on a plane, render it and then try get RGBA data from it using ncplane_as_rgba - you will get NULL. But if you load an image with some background - function will work properly. Same behavior if the plane is not filled, but have some graphics on it.

Code

#include <notcurses/notcurses.h>
int main(int argc, char **argv) 
{   
    struct notcurses *nc = notcurses_init(NULL, stdout);
    struct ncplane *std_plane = notcurses_stdplane(nc);
    struct ncvisual_options opts; 

    memset(&opts, 0, sizeof(struct ncvisual_options));
    opts.n = std_plane;
    opts.x = 0;
    opts.y = 0;
    opts.begy = 0;
    opts.begx = 0;
    opts.lenx = ncplane_dim_x(std_plane);
    opts.leny = ncplane_dim_y(std_plane); 
    opts.blitter = NCBLIT_1x1;
    opts.pxoffx = 0;
    opts.pxoffy = 0;

    struct ncvisual *visual = ncvisual_from_file("test.png");
    ncvisual_resize(visual, opts.leny, opts.lenx);
    std_plane = ncvisual_blit(nc, visual, &opts);
    notcurses_render(nc);
    
    uint32_t *data = ncplane_as_rgba(std_plane, NCBLIT_1x1, 0, 0, ncplane_dim_y(std_plane), ncplane_dim_x(std_plane), NULL, NULL);
    if (data == NULL) {
        notcurses_stop(nc);
        fprintf(stderr, "Can't get rgba array\n");
        exit(EXIT_FAILURE);
    }
    notcurses_stop(nc);
    return EXIT_SUCCESS;
}
@Albrict Albrict added the bug Something isn't working label Aug 2, 2023
@Albrict Albrict changed the title ncplane_as_rgba returns NULL after a blitting transparent background image on a plane ncplane_as_rgba returns NULL after a blitting image with transparent background on a plane Aug 2, 2023
@dankamongmen dankamongmen self-assigned this Aug 3, 2023
@dankamongmen dankamongmen added this to the 3.1.0 milestone Aug 3, 2023
@dankamongmen
Copy link
Owner

thanks for the quality report! i'll look into this asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants