Documentation
¶
Index ¶
- Variables
- func FixedToFloat(v int32) float64
- func FloatToFixed(v float64) int32
- type Capability
- type ConstraintType
- type Context
- type Device
- func (d *Device) Cancel()
- func (d *Device) Close() error
- func (d *Device) FindOption(name string) (int, *OptionDescriptor, error)
- func (d *Device) GetOptionBool(index int) (bool, error)
- func (d *Device) GetOptionDescriptor(index int) (*OptionDescriptor, error)
- func (d *Device) GetOptionDescriptors() ([]OptionDescriptor, error)
- func (d *Device) GetOptionFixed(index int) (float64, error)
- func (d *Device) GetOptionInt(index int) (int, error)
- func (d *Device) GetOptionString(index int) (string, error)
- func (d *Device) GetParameters() (Parameters, error)
- func (d *Device) GetSelectFD() (int, error)
- func (d *Device) Name() string
- func (d *Device) OptionCount() (int, error)
- func (d *Device) PressButton(index int) (Info, error)
- func (d *Device) ScanImage() (image.Image, error)
- func (d *Device) SetNonBlocking(nonBlocking bool) error
- func (d *Device) SetOptionAuto(index int) (Info, error)
- func (d *Device) SetOptionBool(index int, val bool) (Info, error)
- func (d *Device) SetOptionByName(name string, value any) (Info, error)
- func (d *Device) SetOptionFixed(index int, val float64) (Info, error)
- func (d *Device) SetOptionInt(index int, val int) (Info, error)
- func (d *Device) SetOptionString(index int, val string) (Info, error)
- func (d *Device) Start() error
- type DeviceInfo
- type Frame
- type Info
- type OptionDescriptor
- type Parameters
- type Range
- type RangeFixed
- type ScanReader
- type Status
- type Unit
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var ( ErrGood = StatusGood ErrUnsupported = StatusUnsupported ErrCancelled = StatusCancelled ErrDeviceBusy = StatusDeviceBusy ErrInval = StatusInval ErrEOF = StatusEOF ErrJammed = StatusJammed ErrNoDocs = StatusNoDocs ErrCoverOpen = StatusCoverOpen ErrIOError = StatusIOError ErrNoMem = StatusNoMem ErrAccessDenied = StatusAccessDenied // Wrapper specific errors ErrClosed = errors.New("sane: handle is closed") ErrInvalidType = errors.New("sane: invalid option type") ErrNotFound = errors.New("sane: option not found") ErrBufferTooSmall = errors.New("sane: buffer too small") )
Sentinel errors corresponding to SANE status codes.
Functions ¶
func FixedToFloat ¶
FixedToFloat converts a SANE 16.16 fixed-point representation to float64.
func FloatToFixed ¶
FloatToFixed converts a float64 to SANE 16.16 fixed-point representation.
Types ¶
type Capability ¶
type Capability int
Capability flags for SANE options.
const ( CapSoftSelect Capability = C.SANE_CAP_SOFT_SELECT CapHardSelect Capability = C.SANE_CAP_HARD_SELECT CapSoftDetect Capability = C.SANE_CAP_SOFT_DETECT CapEmulated Capability = C.SANE_CAP_EMULATED CapAutomatic Capability = C.SANE_CAP_AUTOMATIC CapInactive Capability = C.SANE_CAP_INACTIVE CapAdvanced Capability = C.SANE_CAP_ADVANCED )
type ConstraintType ¶
type ConstraintType int
ConstraintType describes how the value of an option is constrained.
const ( ConstraintNone ConstraintType = C.SANE_CONSTRAINT_NONE ConstraintRange ConstraintType = C.SANE_CONSTRAINT_RANGE ConstraintWordList ConstraintType = C.SANE_CONSTRAINT_WORD_LIST ConstraintStringList ConstraintType = C.SANE_CONSTRAINT_STRING_LIST )
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context manages the lifecycle of the SANE library session.
func (*Context) GetDevices ¶
func (c *Context) GetDevices(localOnly bool) ([]DeviceInfo, error)
GetDevices returns a list of available SANE devices. If localOnly is true, only locally connected devices are queried.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents an opened SANE device.
func (*Device) Cancel ¶
func (d *Device) Cancel()
Cancel cancels the current scan operation immediately.
func (*Device) FindOption ¶
func (d *Device) FindOption(name string) (int, *OptionDescriptor, error)
FindOption finds an option descriptor and its index by its name (e.g. "mode", "resolution", "source").
func (*Device) GetOptionBool ¶
GetOptionBool reads a boolean option value.
func (*Device) GetOptionDescriptor ¶
func (d *Device) GetOptionDescriptor(index int) (*OptionDescriptor, error)
GetOptionDescriptor retrieves the descriptor for the option at the given index.
func (*Device) GetOptionDescriptors ¶
func (d *Device) GetOptionDescriptors() ([]OptionDescriptor, error)
GetOptionDescriptors returns all option descriptors for the device.
func (*Device) GetOptionFixed ¶
GetOptionFixed reads a fixed-point option value as float64.
func (*Device) GetOptionInt ¶
GetOptionInt reads an integer option value.
func (*Device) GetOptionString ¶
GetOptionString reads a string option value.
func (*Device) GetParameters ¶
func (d *Device) GetParameters() (Parameters, error)
GetParameters fetches the current scan parameters from the device.
func (*Device) GetSelectFD ¶
GetSelectFD returns a file descriptor suitable for select/poll/epoll when non-blocking mode is enabled.
func (*Device) OptionCount ¶
OptionCount returns the total number of options available on the device.
func (*Device) PressButton ¶
PressButton activates a button-type option.
func (*Device) ScanImage ¶
ScanImage executes a full scan and decodes the image into an image.Image. Supports Gray (1-bit, 8-bit, 16-bit) and RGB (8-bit, 16-bit), including multi-frame RGB.
func (*Device) SetNonBlocking ¶
SetNonBlocking enables or disables non-blocking I/O mode for sane_read.
func (*Device) SetOptionAuto ¶
SetOptionAuto requests the backend to automatically set the option value.
func (*Device) SetOptionBool ¶
SetOptionBool sets a boolean option value.
func (*Device) SetOptionByName ¶
SetOptionByName sets an option value by its name dynamically resolving the type.
func (*Device) SetOptionFixed ¶
SetOptionFixed sets a fixed-point option value from float64.
func (*Device) SetOptionInt ¶
SetOptionInt sets an integer option value.
func (*Device) SetOptionString ¶
SetOptionString sets a string option value.
type DeviceInfo ¶
DeviceInfo represents the information of a discovered SANE device.
type Frame ¶
type Frame int
Frame specifies the image frame format.
const ( FrameGray Frame = C.SANE_FRAME_GRAY FrameRGB Frame = C.SANE_FRAME_RGB FrameRed Frame = C.SANE_FRAME_RED FrameGreen Frame = C.SANE_FRAME_GREEN FrameBlue Frame = C.SANE_FRAME_BLUE )
type Info ¶
type Info int
Info flags returned by sane_control_option.
const ( InfoInexact Info = C.SANE_INFO_INEXACT InfoReloadOptions Info = C.SANE_INFO_RELOAD_OPTIONS InfoReloadParams Info = C.SANE_INFO_RELOAD_PARAMS )
type OptionDescriptor ¶
type OptionDescriptor struct {
Index int
Name string
Title string
Description string
Type ValueType
Unit Unit
Size int
Capabilities Capability
ConstraintType ConstraintType
StringList []string
WordList []int
WordListFixed []float64
Range *Range
RangeFixed *RangeFixed
}
OptionDescriptor describes an option of a SANE device.
func (*OptionDescriptor) IsActive ¶
func (o *OptionDescriptor) IsActive() bool
IsActive returns true if the option is active.
func (*OptionDescriptor) IsSettable ¶
func (o *OptionDescriptor) IsSettable() bool
IsSettable returns true if the option value can be set by software.
type Parameters ¶
type Parameters struct {
Format Frame
LastFrame bool
BytesPerLine int
PixelsPerLine int
Lines int
Depth int
}
Parameters holds the scan acquisition parameters.
type RangeFixed ¶
RangeFixed defines min, max, and quantization step in float64 for fixed-point options.
type ScanReader ¶
type ScanReader struct {
// contains filtered or unexported fields
}
ScanReader implements io.Reader streaming image bytes directly from sane_read.
func NewScanReader ¶
func NewScanReader(device *Device) *ScanReader
NewScanReader creates a ScanReader for an active scan on device.
func (*ScanReader) Close ¶
func (r *ScanReader) Close() error
Close cancels any ongoing scan on the reader.
type Status ¶
type Status int
Status represents the SANE status code.
const ( StatusGood Status = C.SANE_STATUS_GOOD StatusUnsupported Status = C.SANE_STATUS_UNSUPPORTED StatusCancelled Status = C.SANE_STATUS_CANCELLED StatusDeviceBusy Status = C.SANE_STATUS_DEVICE_BUSY StatusInval Status = C.SANE_STATUS_INVAL StatusEOF Status = C.SANE_STATUS_EOF StatusJammed Status = C.SANE_STATUS_JAMMED StatusNoDocs Status = C.SANE_STATUS_NO_DOCS StatusCoverOpen Status = C.SANE_STATUS_COVER_OPEN StatusIOError Status = C.SANE_STATUS_IO_ERROR StatusNoMem Status = C.SANE_STATUS_NO_MEM StatusAccessDenied Status = C.SANE_STATUS_ACCESS_DENIED )
type Unit ¶
type Unit int
Unit specifies the physical unit of an option.
const ( UnitNone Unit = C.SANE_UNIT_NONE UnitPixel Unit = C.SANE_UNIT_PIXEL UnitBit Unit = C.SANE_UNIT_BIT UnitMM Unit = C.SANE_UNIT_MM UnitDPI Unit = C.SANE_UNIT_DPI UnitPercent Unit = C.SANE_UNIT_PERCENT UnitMicrosecond Unit = C.SANE_UNIT_MICROSECOND )
type ValueType ¶
type ValueType int
ValueType specifies the data type of an option.
const ( TypeBool ValueType = C.SANE_TYPE_BOOL TypeInt ValueType = C.SANE_TYPE_INT TypeFixed ValueType = C.SANE_TYPE_FIXED TypeString ValueType = C.SANE_TYPE_STRING TypeButton ValueType = C.SANE_TYPE_BUTTON TypeGroup ValueType = C.SANE_TYPE_GROUP )