al_get_video_frame(3alleg5)
π al_get_video_frame π
okay bestie, welcome to the Allegro 5 API β¨ this one lives in the alleg5 manual and it's literally the moment your video finally shows you a picture π¬π¦
πΈ SYNOPSIS πΈ
#include <allegro5/allegro_video.h>
ALLEGRO_BITMAP *al_get_video_frame(ALLEGRO_VIDEO *video)
β¨ DESCRIPTION β¨
so this one hands you the current video frame. that's it, that's the whole vibe π
β οΈ IMPORTANT β οΈ the bitmap is owned by the video, so do NOT try to free it. nope. don't. put the free() down. π
and like, it stays valid until the next call to al_get_video_frame β so if you're holding onto it, you better be done with it before you call this again, fr fr π
π the pixel situation π
ngl this is the part that gets people: videos often do not use square pixels. so the recommended way to draw a video frame is code like this β this is the move, bestie, this is what slays π
float scale = 1.0; /* Adjust this to fit your target bitmap dimensions. */
ALLEGRO_BITMAP* frame = al_get_video_frame(video);
float sw = al_get_bitmap_width(frame);
float sh = al_get_bitmap_height(frame);
float dw = scale * al_get_video_scaled_width(video);
float dh = scale * al_get_video_scaled_height(video);
al_draw_scaled_bitmap(frame, 0, 0, sw, sh, 0, 0, dw, dh, 0);
see how it pulls sw and sh from the frame but dw and dh from the scaled width and height? that's the whole trick, iykyk π§β¨
π¦ SINCE π¦
5.1.0 β she's been iconic since day one, no cap π
π SEE ALSO π
those two are the ones doing the heavy lifting in that example above, so go say hi π«Ά
and that's the page!! brought to you by the Allegro reference manual for al_get_video_frame(3alleg5) β go get that frame, bestie, you're the main character πππ
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms