1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/// The META_SETROP2 Record defines the foreground raster operation mix mode in
/// the playback device context. The foreground mix mode is the mode for
/// combining pens and interiors of filled objects with foreground colors on the
/// output surface.
#[derive(Clone, Debug)]
pub struct META_SETROP2 {
/// RecordSize (4 bytes): A 32-bit unsigned integer that defines the number
/// of WORD structures, defined in [MS-DTYP] section 2.2.61, in the WMF
/// record.
pub record_size: crate::wmf::parser::RecordSize,
/// RecordFunction (2 bytes): A 16-bit unsigned integer that defines this
/// WMF record type. The lower byte MUST match the lower byte of the
/// RecordType Enumeration table value META_SETROP2.
pub record_function: u16,
/// DrawMode (2 bytes): A 16-bit unsigned integer that defines the
/// foreground binary raster operation mixing mode. This MUST be one of the
/// values in the BinaryRasterOperation Enumeration.
pub draw_mode: crate::wmf::parser::BinaryRasterOperation,
/// Reserved (2 bytes): An optional 16-bit field that MUST be ignored.
/// (Windows NT 3.1, Windows NT 3.5, and Windows NT 3.51 implementations do
/// not write this field to WMF metafiles.)
pub reserved: Option<[u8; 2]>,
}
impl META_SETROP2 {
#[cfg_attr(feature = "tracing", tracing::instrument(
level = tracing::Level::TRACE,
skip_all,
fields(
%record_size,
record_function = %format!("{record_function:#06X}"),
),
err(level = tracing::Level::ERROR, Display),
))]
pub fn parse<R: crate::wmf::Read>(
buf: &mut R,
mut record_size: crate::wmf::parser::RecordSize,
record_function: u16,
) -> Result<Self, crate::wmf::parser::ParseError> {
crate::wmf::parser::records::check_lower_byte_matches(
record_function,
crate::wmf::parser::RecordType::META_SETROP2,
)?;
let (draw_mode, draw_mode_bytes) = crate::wmf::parser::BinaryRasterOperation::parse(buf)?;
record_size.consume(draw_mode_bytes);
let reserved = if record_size.byte_count() > 8 {
let (v, c) = crate::wmf::parser::read::<R, 2>(buf)?;
record_size.consume(c);
Some(v)
} else {
None
};
crate::wmf::parser::records::consume_remaining_bytes(buf, record_size)?;
Ok(Self {
record_size,
record_function,
draw_mode,
reserved,
})
}
}