let opts = ptouch::Options::from_args();
let mut pt = PTouch::new(&opts);
let (status, mut pt) = if let Ok(pt) = pt.as_mut() {
(pt.status().unwrap(), Some(pt))
} else {
(Status { error1:Error1::empty(), error2: Error2::empty(), media_kind:MediaKind::LaminatedTape, media_width:12, status_type:DeviceStatus::Unknown, tape_colour:TapeColour::White,
model:0, phase:Phase::Printing, text_colour:TextColour::Black}, None)
};
println!("Status: {:?}", status);
let media = Media::from((status.media_kind, status.media_width));
let ops = [
ops::Op::pad(8),
ops::Op::text("this is a long long long string yes"),
ops::Op::pad(8),
// ops::Op::image("test.png"),
ops::Op::pad(8),
];
let rc = RenderConfig{y: media.area().1 as usize, ..Default::default()};
let mut render = Render::new(rc);
render.render(&ops).unwrap();
let data = render.raster(media.area()).unwrap();
println!("{:?}", data);
render.show().unwrap();
Take this code:
With an image (
test.png: PNG image data, 35 x 70, 8-bit grayscale, non-interlaced
): Raster display size: Size { width: 920, height: 70 } output area: (29, 70, 29) Without (Op::image commented out): Raster display size: Size { width: 447, height: 70 } output area: (29, 70, 29)