Skip to main content

rhwp/emf/parser/objects/
logpen.rs

1//! LogPen — MS-EMF 2.2.19 (16바이트).
2
3use crate::emf::parser::Cursor;
4use crate::emf::Error;
5
6/// 원시 폭의 단위. CREATEPEN의 양수 폭과 EXTLOGPEN의 cosmetic 폭은 다르다.
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum PenWidthKind {
9    Logical,
10    DevicePixel,
11}
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub struct LogPen {
15    pub style: u32, // PenStyle flags
16    pub width: i32, // 원시 lopnWidth.x 또는 elpWidth
17    pub width_kind: PenWidthKind,
18    pub _reserved: i32, // lopnWidth.y (사용 안 함)
19    pub color: u32,     // COLORREF: 0x00BBGGRR
20}
21
22impl LogPen {
23    pub fn read(c: &mut Cursor<'_>) -> Result<Self, Error> {
24        let style = c.u32()?;
25        let width = c.i32()?;
26        Ok(Self {
27            style,
28            width,
29            width_kind: if width == 0 {
30                PenWidthKind::DevicePixel
31            } else {
32                PenWidthKind::Logical
33            },
34            _reserved: c.i32()?,
35            color: c.u32()?,
36        })
37    }
38}