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

Failed to overlay OSD with colors. #300

Open
duiniuluantanqin opened this issue Nov 12, 2024 · 0 comments
Open

Failed to overlay OSD with colors. #300

duiniuluantanqin opened this issue Nov 12, 2024 · 0 comments

Comments

@duiniuluantanqin
Copy link

I want to overlay a text watermark onto a video using SDL_ttf, but failed. Below is my core code.

pl_map_avframe_ex
pl_swapchain_start_frame
pl_frame_from_swapchain

// above is some pseudocode 
... ...

TTF_Font *font = TTF_OpenFont("simsun.ttc", 24);
SDL_Color color = {255, 255, 255, 128};
SDL_Surface *text_surface = TTF_RenderUTF8_Blended(font , "osd_text", color);
upload_plane(text_surface, &osd_tex, &osd_plane);

struct pl_overlay osd;
struct pl_overlay_part osd_part;
if (osd_tex) {
    osd_part = (struct pl_overlay_part) {
        .src = { 0, 0, osd_tex->params.w, osd_tex->params.h },
        .dst = { 0, 0, osd_tex->params.w, osd_tex->params.h },
    };
    osd = (struct pl_overlay) {
        .tex        = osd_tex,
        .mode       = PL_OVERLAY_NORMAL,
        .repr       = image.repr,
        .color      = image.color,
        .coords     = PL_OVERLAY_COORDS_DST_FRAME,
        .parts      = &osd_part,
        .num_parts  = 1,
    };
    target.overlays = &osd;
    target.num_overlays = 1;
}

pl_render_image(renderer, image, target, &pl_render_default_params)

... ...
// below is some pseudocode 
pl_swapchain_submit_frame
pl_swapchain_swap_buffers

the function upload_plane is copy from demos\sdlimage.c

When I try to display white text, I get light purple instead. And other tests are shown below.
{255, 255, 255, 128} ----> expecting white but got light purple
{255, 0, 0, 0} ----> red
{0, 255, 0, 0} ----> expecting green but got blue.
{0, 0, 255, 0} ----> expecting blue but got green.

Also, I tried adjusting the order of the four variables below, but it still failed.
uint64_t masks[4] = { fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant