use crate::emf::parser::{
objects::{LogBrush, LogFontW, LogPen, PenWidthKind},
Cursor,
};
use crate::emf::Error;
pub fn parse_create_pen(c: &mut Cursor<'_>) -> Result<(u32, LogPen), Error> {
let handle = c.u32()?;
let pen = LogPen::read(c)?;
Ok((handle, pen))
}
pub fn parse_ext_create_pen(c: &mut Cursor<'_>) -> Result<(u32, LogPen), Error> {
let handle = c.u32()?;
for _ in 0..4 {
let _ = c.u32()?;
}
let style = c.u32()?;
let width = c.u32()? as i32;
let _brush_style = c.u32()?;
let color = c.u32()?;
Ok((
handle,
LogPen {
style,
width,
width_kind: if style & 0x0001_0000 != 0 {
PenWidthKind::Logical
} else {
PenWidthKind::DevicePixel
},
_reserved: 0,
color,
},
))
}
pub fn parse_create_brush_indirect(c: &mut Cursor<'_>) -> Result<(u32, LogBrush), Error> {
let handle = c.u32()?;
let brush = LogBrush::read(c)?;
Ok((handle, brush))
}
pub fn parse_ext_create_font_indirect_w(
c: &mut Cursor<'_>,
payload_len: usize,
) -> Result<(u32, LogFontW), Error> {
let handle = c.u32()?;
let font = LogFontW::read(c)?;
let consumed = 4 + 92;
if payload_len > consumed {
let _ = c.take(payload_len - consumed)?;
}
Ok((handle, font))
}
pub fn parse_select_object(c: &mut Cursor<'_>) -> Result<u32, Error> {
c.u32()
}
pub fn parse_delete_object(c: &mut Cursor<'_>) -> Result<u32, Error> {
c.u32()
}