sub_image/formats/
image.rs1use std::path::Path;
3
4use crate::formats::sub::SubInfo;
6use crate::formats::subs::GroupSubInfo;
7
8use anyhow::{Result};
10use image::DynamicImage;
11use image::io::Reader;
12
13
14#[derive(Default)]
15pub struct UnifiedImage {
16 pub groups: Vec<GroupSubInfo>,
17 pub subs: Vec<SubInfo>,
18 image: DynamicImage
19}
20
21
22impl UnifiedImage {
23 pub fn from_file(path: &Path) -> Result<Self> {
24 let image = Reader::open(path)?.decode()?;
25
26 Ok(Self {
27 groups: vec![],
28 subs: vec![],
29 image
30 })
31 }
32
33 pub fn name(&self) -> String {
34 "test".to_owned()
35 }
36
37 pub fn add_sub(&mut self, info: SubInfo) {
38 self.subs.push(info);
39 }
40
41 pub fn add_subs_group(&mut self, group: GroupSubInfo) {
42 self.groups.push(group);
43 }
44
45 pub fn slice_subs(self) -> Vec<UnifiedImage> {
46 todo!()
47 }
48}
49