Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7822639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:58:40+00:00 2026-06-02T07:58:40+00:00

Working on a YUV-viewer in python using pygame . The code below displays one

  • 0

Working on a YUV-viewer in python using pygame.

The code below displays one frame of YUV 4:2:0

#!/usr/bin/env python

import pygame

W = 352
H = 288
WH = (W, H)

pygame.init()
screen = pygame.display.set_mode(WH)

overlay = pygame.Overlay(pygame.YV12_OVERLAY, WH)

fd = open('foreman.yuv', 'rb')
y = fd.read(W * H)
u = fd.read(W * H / 4)
v = fd.read(W * H / 4)

overlay = pygame.Overlay(pygame.YV12_OVERLAY, WH)

overlay.display((y, u, v))

This code displays a 16×16 semi-transparent rectangle in position (0,0)

pygame.init()
screen = pygame.display.set_mode(WH)

s = pygame.Surface((16,16))
s.set_alpha(128)
s.fill((255,255,255))
screen.blit(s, (0,0))
pygame.display.flip()

But, how do I combine them? I.e. how do I display a semi-transparent rectangle in position (0,0) on top of the YUV-data so that the YUV-data can be seen through the rectangle?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:58:42+00:00Added an answer on June 2, 2026 at 7:58 am

    It’s an OVERLAY. You can’t put other stuff “on top” of it: from the docs:

    The overlay objects are always visible, and always show above the
    regular display contents.

    YUV overlays tap into hardware normally used by media players to display video. The content is typically never written to a “framebuffer” as such (causing endless grief with blank areas for screenshot/screen-capture software etc).

    So you’d have to draw what you want to add over it directly “into” the y,u,v data. (Or convert the y,u,v data to RGB data and display it by more conventional means).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
Working on a program in python to print out the first 1000 prime numbers
Working with an api and I need to one of the first responses alongside
Working with Json, how can I NSlog only the title in this code: NSDictionary
Working with box2d and cocos2d, I've calculated two vectors: one is the vector pointing
Working on a maintenance project, I am struggling with lot of messy code. In
Working SQL The following code works as expected, returning two columns of data (a
Working with COM interop, I can call a managed function from within unmanaged code.
Working on a console application using Delphi 7, and have run into a problem.
working on an old translation sample code for windows phone 7. Recently, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.