summaryrefslogtreecommitdiffstats
path: root/sub/sub.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-07 03:26:46 +0200
committerwm4 <wm4@nowhere>2012-10-24 21:56:33 +0200
commitc139cd2b936a6824238264aa974aa5cfa55caa25 (patch)
tree5865b78fb3cdecb0fe0b8fc15bacc27cc61509c6 /sub/sub.c
parent0e72b0d5d3aeae5c4a04ca1baceda3ceb2d63ce3 (diff)
downloadmpv-c139cd2b936a6824238264aa974aa5cfa55caa25.tar.bz2
mpv-c139cd2b936a6824238264aa974aa5cfa55caa25.tar.xz
sub: add function to draw OSD into an image
The osd_draw_on_image() function renders the full OSD into the provided image. It uses the mp_draw_sub_bitmaps() function added in the previous commit to do the actual work.
Diffstat (limited to 'sub/sub.c')
-rw-r--r--sub/sub.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sub/sub.c b/sub/sub.c
index b37ec07747..f175563974 100644
--- a/sub/sub.c
+++ b/sub/sub.c
@@ -37,6 +37,7 @@
#include "sub.h"
#include "dec_sub.h"
#include "img_convert.h"
+#include "draw_bmp.h"
#include "spudec.h"
@@ -300,6 +301,30 @@ void draw_osd_with_eosd(struct vo *vo, struct osd_state *osd)
}
}
+// Returns whether anything was drawn.
+bool osd_draw_on_image(struct osd_state *osd, struct mp_image *dest,
+ struct mp_csp_details *dest_csp,
+ struct sub_render_params *sub_params)
+{
+ static const bool formats[SUBBITMAP_COUNT] = {
+ [SUBBITMAP_LIBASS] = true,
+ [SUBBITMAP_RGBA] = true,
+ };
+ bool changed = false;
+ osd_update_ext(osd, sub_params->dim);
+ for (int n = 0; n < MAX_OSD_PARTS; n++) {
+ struct osd_object *obj = osd->objs[n];
+ if (obj->is_sub && osd->render_subs_in_filter)
+ continue;
+ struct sub_bitmaps imgs;
+ if (render_object(osd, obj, &imgs, sub_params, formats)) {
+ mp_draw_sub_bitmaps(dest, &imgs, dest_csp);
+ changed = true;
+ }
+ }
+ return changed;
+}
+
void osd_draw_text_ext(struct osd_state *osd, int w, int h,
int ml, int mt, int mr, int mb, int unused0, int unused1,
void (*draw_alpha)(void *ctx, int x0, int y0, int w,