Documentation ¶
Index ¶
- Constants
- func New() (*lisgo, error)
- func SetLisLogLevel(lvl uint32)
- type CErrorProxy
- type LisValue
- type OptionConstraint
- type OptionDescriptor
- type PageReader
- func (sb *PageReader) GetImage() (image.Image, error)
- func (sb *PageReader) Read(p []byte) (int, error)
- func (sb *PageReader) ReadToEnd() ([]byte, error)
- func (sb *PageReader) WriteToFile(name string, format string) error
- func (sb *PageReader) WriteToJpeg(name string) error
- func (sb *PageReader) WriteToPng(name string) error
- type PaperSource
- type ScanParameters
- type ScanSession
- type Scanner
- type ValueList
- type ValueRange
Constants ¶
const ( LisLogLvlMin uint32 = 0 LisLogLvlDebug uint32 = LisLogLvlMin LisLogLvlInfo uint32 = 1 LisLogLvlWarning uint32 = 2 LisLogLvlError uint32 = 3 LisLogLvlMax uint32 = LisLogLvlError )
Log levels from libinsane
const ( LisTypeBool = iota LisTypeInteger LisTypeDouble LisTypeString LisTypeImageFormat )
lis_value_type enum
const ( LisConstraintNone = iota LisConstraintRange LisConstraintList )
lis_constraint_type enum
const ( LisCapEmulated = 1 << 0 // emulated option (either by LibInsane or backend) LisCapAutomatic = 1 << 1 // can be set automatically by the driver LisCapHwSelect = 1 << 2 // can be set by a hardware switch LisCapSwSelect = 1 << 3 // read/write ; can be set by software LisCapInactive = 1 << 4 //requires another option to be set to a specific value to become active )
capabilitites bit mask flags
const ( /* Raw image, 24bits per pixel. * * For each pixel: * - 8bits for red, * - 8bits for green, * - 8bits for blue. * * No header, just pixels. */ LisImgFormatRawRGB24 = iota LisImgFormatGrayScale8 LisImgFormatBW1 LisImgFormatBmp LisImgFormatCiff LisImgFormatExif LisImgFormatFlashPix LisImgFormatGif LisImgFormatJpeg LisImgFormatPng LisImgFormatIco LisImgFormatJpeg2k LisImgFormatJpeg2kx LisImgFormatmMemoryBmp // Windows BMP without header LisImgFormatPhotoCD LisImgFormatPict LisImgFormatTiff )
* Image format. * * Used to defined the type of content that will be returned by \ref lis_scan_session.scan_read() .
const ( LisUnitNone = iota LisUnitPixel LisUnitBit LisUnitMM LisUnitDPI LisUnitPercent LisUnitMicrosecond )
enum lis_unit
const (
LisOk uint32 = 0
)
Lis errors
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CErrorProxy ¶
type CErrorProxy struct {
// contains filtered or unexported fields
}
CErrorProxy wraps errors in C code, the idea is to reuse pre-allocated buffer when calling C function proxies
func (*CErrorProxy) ErrNum ¶
func (e *CErrorProxy) ErrNum() uint32
ErrNum returns number of error which we've got from C-code
func (*CErrorProxy) Error ¶
func (e *CErrorProxy) Error() string
func (*CErrorProxy) FreeBuffer ¶
func (e *CErrorProxy) FreeBuffer()
FreeBuffer releases allocated memory
func (*CErrorProxy) GetProxy ¶
func (e *CErrorProxy) GetProxy() *C.struct_error_proxy
GetProxy returns address of internal struct error_proxy
type LisValue ¶
type LisValue struct { ValType uint32 BoolValue bool IntValue int DoubleValue float64 StringValue string ImgFormat C.enum_lis_img_format }
LisValue is value of option
func NewValue ¶
func NewValue(val *C.union_lis_value, typ C.enum_lis_value_type) *LisValue
NewValue constructs GO LisValue struct from lis_value C-struct
type OptionConstraint ¶
type OptionConstraint struct { /* LIS_CONSTRAINT_NONE = 0, No constraint LIS_CONSTRAINT_RANGE = 1, Range of values (integers only) LIS_CONSTRAINT_LIST = 2, The structure 'possible' contains a list of values */ ConstraintType int //If LIS_CONSTRAINT_RANGE. PossibleRange *ValueRange //If LIS_CONSTRAINT_LIST. PossibleList ValueList }
OptionConstraint describe restrictions defining the possible values for this option.
func NewConstraint ¶
func NewConstraint(valType C.enum_lis_value_type, conType C.int, conPossible unsafe.Pointer) *OptionConstraint
NewConstraint costructs Go ValueConstraint struct from C-structs
type OptionDescriptor ¶
type OptionDescriptor struct { //Name option name / identifier (ex: "source", "resolution", etc). Name string //Title Human readable title (usually in English). Title string //Desc Human readable description (usually in English). Desc string /* Capabilities is the option capabilities. * * Bit fields: * - LIS_CAP_EMULATED * - LIS_CAP_AUTOMATIC * - LIS_CAP_HW_SELECT * - LIS_CAP_SW_SELECT * - LIS_CAP_INACTIVE */ Capabilities int // Type of this option. ValueType C.enum_lis_value_type // Unit of this value. Only useful for integers and float. ValueUnit C.enum_lis_unit Constraint *OptionConstraint // contains filtered or unexported fields }
OptionDescriptor is a definition of an scan option
func (*OptionDescriptor) GetValue ¶
func (o *OptionDescriptor) GetValue() (*LisValue, error)
GetValue obtains value of an option
func (*OptionDescriptor) IsReadable ¶
func (o *OptionDescriptor) IsReadable() bool
IsReadable indicates that option can be read
func (*OptionDescriptor) IsWritable ¶
func (o *OptionDescriptor) IsWritable() bool
IsWritable indicates that option can be written
type PageReader ¶
type PageReader struct { Width int Height int Format uint32 ImageSize uint Session *ScanSession }
PageReader represents a single page received from scanner
func NewPageReader ¶
func NewPageReader(session *ScanSession, param *ScanParameters) *PageReader
NewPageReader converts data buffer to image object
func (*PageReader) Read ¶
func (sb *PageReader) Read(p []byte) (int, error)
Read portion of data from scanner into a buffer
func (*PageReader) WriteToFile ¶
func (sb *PageReader) WriteToFile(name string, format string) error
func (*PageReader) WriteToJpeg ¶
func (sb *PageReader) WriteToJpeg(name string) error
WriteToJpeg writes image to file
func (*PageReader) WriteToPng ¶
func (sb *PageReader) WriteToPng(name string) error
WriteToPng writes image to file
type PaperSource ¶
type PaperSource struct { Name string Kind C.enum_lis_item_type // contains filtered or unexported fields }
PaperSource represents a source of paper for scan, i.e flatbed or automatic feeder
func (*PaperSource) IterateOptions ¶
func (s *PaperSource) IterateOptions(f func(*OptionDescriptor) bool) error
IterateOptions iterates thru options of the paper source
func (*PaperSource) ScanStart ¶
func (s *PaperSource) ScanStart() (*ScanSession, error)
ScanStart creates scanning session
type ScanParameters ¶
type ScanParameters struct {
// contains filtered or unexported fields
}
ScanParameters holds the current scan session's parameters
func (*ScanParameters) Height ¶
func (sp *ScanParameters) Height() int
Height of the image in pixels. warning This value is *not* guaranteed to be true when scanning.
func (*ScanParameters) ImageFormat ¶
func (sp *ScanParameters) ImageFormat() uint32
ImageFormat is image format. This value is guaranteed to be true when scanning.
func (*ScanParameters) ImageFormatStr ¶
func (sp *ScanParameters) ImageFormatStr() string
ImageFormatStr returns name of the image format
func (*ScanParameters) ImageSize ¶
func (sp *ScanParameters) ImageSize() uint
ImageSize is estimated image size in bytes. Can be used to pre-allocate memory. This value is *not* guaranteed to be true when scanning.
func (*ScanParameters) String ¶
func (sp *ScanParameters) String() string
func (*ScanParameters) Width ¶
func (sp *ScanParameters) Width() int
Width of the image in pixels. This value is guaranteed to be true when scanning
type ScanSession ¶
type ScanSession struct {
// contains filtered or unexported fields
}
ScanSession is just a scan session
func (*ScanSession) Cancel ¶
func (s *ScanSession) Cancel()
func (*ScanSession) Close ¶
func (s *ScanSession) Close()
DEPRECATED: Close frees all allocated resources
func (*ScanSession) EndOfFeed ¶
func (s *ScanSession) EndOfFeed() bool
EndOfFeed indicates that there are no more to read from scanner
func (*ScanSession) EndOfPage ¶
func (s *ScanSession) EndOfPage() bool
EndOfPage indicates that the current page is over
func (*ScanSession) GetScanParameters ¶
func (s *ScanSession) GetScanParameters() (*ScanParameters, error)
GetScanParameters returns scanning session parameters
type Scanner ¶
type Scanner struct { DeviceID string Vendor string Model string Type string // contains filtered or unexported fields }
Scanner is a descriptor of scanner
func (*Scanner) Close ¶
func (d *Scanner) Close()
Close should be called after Open to release associated resources
func (*Scanner) GetPaperSource ¶
func (d *Scanner) GetPaperSource(name string) (*PaperSource, error)
GetPaperSource returns paper source with specified name if any. Otherwise it returns nil.
func (*Scanner) IterateSources ¶
func (d *Scanner) IterateSources(f func(*PaperSource) bool) error
IterateSources iterates thru paper sources
type ValueRange ¶
ValueRange define constraints applied to value