ptouch-label/ptouch-print のオプション整理と trim-right 対応を反映

CLIヘルプ文言を簡潔化しつつ、右余白トリム機能と関連API・ドキュメント更新をまとめて取り込み、PNG/SVG/テンプレート経路での利用体験を揃える。

Made-with: Cursor
This commit is contained in:
knb
2026-04-16 19:09:37 +09:00
parent 32ab12f661
commit 094f183994
13 changed files with 272 additions and 24 deletions

View File

@@ -115,6 +115,29 @@ module Libptouch
[bytes, out_params[:width_dots], out_params[:height_dots]]
end
def trim_right_blank_columns(data, width_dots:, height_dots:, margin_mm: 0, right_padding_dots: 0)
in_params = Binding::RasterParams.new
in_params[:width_dots] = width_dots
in_params[:height_dots] = height_dots
in_params[:margin_mm] = margin_mm
in_buf = FFI::MemoryPointer.new(:uint8, data.bytesize)
in_buf.put_bytes(0, data)
out_pp = FFI::MemoryPointer.new(:pointer)
out_len = FFI::MemoryPointer.new(:size_t)
out_params = Binding::RasterParams.new
raise_on_error(Binding.libptouch_trim_right_blank_columns(
@native, in_buf, data.bytesize, in_params.pointer,
right_padding_dots, out_pp, out_len, out_params.pointer
))
raw = out_pp.read_pointer
raise Libptouch::Error.new(OK, "null raster from trim_right_blank_columns") if raw.null?
len = out_len.get(:size_t, 0)
bytes = raw.read_bytes(len)
Binding.libptouch_free_raster(raw)
[bytes, out_params[:width_dots], out_params[:height_dots]]
end
def status_bytes
buf = FFI::MemoryPointer.new(:uint8, STATUS_LENGTH)
raise_on_error(Binding.libptouch_get_status(@native, buf))