use std::{env, error::Error, fs::File, io::BufWriter}; use libass::{DefaultFontProvider, Layer, Library}; fn draw_layer(layer: Layer, dst: &mut [u8]) { // RGBA order let mut color = layer.color.to_be_bytes(); color[3] = 255 - color[3]; // Inverse alpha for y in 0..layer.height as usize { for x in 0..layer.width as usize { let k = layer.bitmap[y * layer.width as usize + x] as u16; let dst_x = x + layer.x as usize; let dst_y = y + layer.y as usize; let dst_p = (dst_y * 1920 + dst_x) * 4; for i in 0..4 { let dst_off = dst_p + i; let dst_orig = dst[dst_off] as u16; dst[dst_off] = ((k * color[i] as u16 + (255 - k) * dst_orig) / 255) as u8; } } } } fn main() -> Result<(), Box> { let args: Vec = env::args().collect(); if args.len() < 4 { eprintln!("usage: {}