Implement DefineBits and JpegTables tags
This commit is contained in:
parent
461ab7ad15
commit
b563cf7d83
15
src/read.rs
15
src/read.rs
|
@ -409,6 +409,15 @@ impl<R: Read> Reader<R> {
|
|||
data: data,
|
||||
}
|
||||
},
|
||||
Some(TagCode::DefineBits) => {
|
||||
let id = tag_reader.read_u16()?;
|
||||
let mut jpeg_data = Vec::with_capacity(length - 2);
|
||||
tag_reader.input.read_to_end(&mut jpeg_data)?;
|
||||
Tag::DefineBits {
|
||||
id: id,
|
||||
jpeg_data: jpeg_data,
|
||||
}
|
||||
},
|
||||
Some(TagCode::DefineButton) => try!(tag_reader.read_define_button()),
|
||||
Some(TagCode::DefineButton2) => try!(tag_reader.read_define_button_2()),
|
||||
Some(TagCode::DefineButtonCxform) => {
|
||||
|
@ -500,6 +509,12 @@ impl<R: Read> Reader<R> {
|
|||
Tag::ImportAssets { url: url, imports: imports }
|
||||
},
|
||||
|
||||
Some(TagCode::JpegTables) => {
|
||||
let mut data = Vec::with_capacity(length);
|
||||
tag_reader.input.read_to_end(&mut data)?;
|
||||
Tag::JpegTables(data)
|
||||
},
|
||||
|
||||
Some(TagCode::Metadata) => Tag::Metadata(try!(tag_reader.read_c_string())),
|
||||
|
||||
Some(TagCode::SetBackgroundColor) => {
|
||||
|
|
|
@ -10,7 +10,7 @@ pub enum TagCode {
|
|||
RemoveObject = 5,
|
||||
DefineBits = 6,
|
||||
DefineButton = 7,
|
||||
JpefTables = 8,
|
||||
JpegTables = 8,
|
||||
SetBackgroundColor = 9,
|
||||
DefineFont = 10,
|
||||
DefineText = 11,
|
||||
|
|
|
@ -29,6 +29,19 @@ pub fn tag_tests() -> Vec<TagTestData> { vec![
|
|||
read_tag_bytes_from_file("tests/swfs/definebinarydata.swf", TagCode::DefineBinaryData)
|
||||
),
|
||||
|
||||
(
|
||||
1,
|
||||
Tag::DefineBits {
|
||||
id: 1,
|
||||
jpeg_data: vec![
|
||||
255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 192,
|
||||
0, 17, 8, 0, 5, 0, 6, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, 255, 218, 0, 12, 3, 1, 0, 2,
|
||||
17, 3, 17, 0, 63, 0, 252, 215, 162, 138, 43, 248, 28, 255, 0, 180, 3, 255, 217
|
||||
],
|
||||
},
|
||||
read_tag_bytes_from_file("tests/swfs/DefineBits-JpegTables-MX.swf", TagCode::DefineBits)
|
||||
),
|
||||
|
||||
(
|
||||
1,
|
||||
Tag::DefineButton(Box::new(Button {
|
||||
|
@ -538,6 +551,40 @@ pub fn tag_tests() -> Vec<TagTestData> { vec![
|
|||
read_tag_bytes_from_file("tests/swfs/importassets2.swf", TagCode::ImportAssets2)
|
||||
),
|
||||
|
||||
(
|
||||
1,
|
||||
Tag::JpegTables(vec![
|
||||
255, 216, 255, 219, 0, 67, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 255, 219, 0, 67, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
255, 196, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5,
|
||||
6, 7, 8, 9, 10, 11, 255, 196, 0, 181, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1,
|
||||
125, 1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145,
|
||||
161, 8, 35, 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24,
|
||||
25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73,
|
||||
74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116,
|
||||
117, 118, 119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148,
|
||||
149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179,
|
||||
180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210,
|
||||
211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233,
|
||||
234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 255, 196, 0, 31, 1, 0, 3, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 196, 0,
|
||||
181, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33,
|
||||
49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35,
|
||||
51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39,
|
||||
40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87,
|
||||
88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121,
|
||||
122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152,
|
||||
153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183,
|
||||
184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214,
|
||||
215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245,
|
||||
246, 247, 248, 249, 250, 255, 217
|
||||
]),
|
||||
read_tag_bytes_from_file("tests/swfs/DefineBits-JpegTables-MX.swf", TagCode::JpegTables)
|
||||
),
|
||||
|
||||
(
|
||||
1,
|
||||
Tag::Metadata("aa!".to_string()),
|
||||
|
|
|
@ -293,6 +293,7 @@ pub enum Tag {
|
|||
|
||||
Protect(Option<String>),
|
||||
DefineBinaryData { id: CharacterId, data: Vec<u8> },
|
||||
DefineBits { id: CharacterId, jpeg_data: Vec<u8> },
|
||||
DefineButton(Box<Button>),
|
||||
DefineButton2(Box<Button>),
|
||||
DefineButtonColorTransform { id: CharacterId, color_transforms: Vec<ColorTransform> },
|
||||
|
@ -307,8 +308,8 @@ pub enum Tag {
|
|||
EnableDebugger(String),
|
||||
EnableTelemetry { password_hash: Vec<u8> },
|
||||
Metadata(String),
|
||||
|
||||
ImportAssets { url: String, imports: Vec<ExportedAsset> },
|
||||
JpegTables(Vec<u8>),
|
||||
SetBackgroundColor(Color),
|
||||
SetTabIndex { depth: Depth, tab_index: u16 },
|
||||
SoundStreamBlock(Vec<u8>),
|
||||
|
|
11
src/write.rs
11
src/write.rs
|
@ -413,6 +413,12 @@ impl<W: Write> Writer<W> {
|
|||
try!(self.output.write_all(&data));
|
||||
},
|
||||
|
||||
&Tag::DefineBits { id, ref jpeg_data } => {
|
||||
self.write_tag_header(TagCode::DefineBits, jpeg_data.len() as u32 + 2)?;
|
||||
self.write_u16(id)?;
|
||||
self.output.write_all(jpeg_data)?;
|
||||
},
|
||||
|
||||
&Tag::DefineButton(ref button) => {
|
||||
try!(self.write_define_button(button))
|
||||
},
|
||||
|
@ -541,6 +547,11 @@ impl<W: Write> Writer<W> {
|
|||
}
|
||||
},
|
||||
|
||||
&Tag::JpegTables(ref data) => {
|
||||
self.write_tag_header(TagCode::JpegTables, data.len() as u32)?;
|
||||
self.output.write_all(data)?;
|
||||
},
|
||||
|
||||
&Tag::Metadata(ref metadata) => {
|
||||
try!(self.write_tag_header(TagCode::Metadata, metadata.len() as u32 + 1));
|
||||
try!(self.write_c_string(metadata));
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue