Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChunkSize ¶
type ChunkSize uint16
const ( ChunkSizeUnknown ChunkSize = 0 ChunkSize32 ChunkSize = ChunkSize(internal.ChunkSize32) ChunkSize64 ChunkSize = ChunkSize(internal.ChunkSize64) ChunkSize128 ChunkSize = ChunkSize(internal.ChunkSize128) ChunkSize256 ChunkSize = ChunkSize(internal.ChunkSize256) ChunkSize512 ChunkSize = ChunkSize(internal.ChunkSize512) ChunkSize1024 ChunkSize = ChunkSize(internal.ChunkSize1024) )
type QRSequence ¶
type QRSequence struct { ChunkSize ChunkSize // contains filtered or unexported fields }
func New ¶
func New(data []byte, chunkSize ChunkSize) *QRSequence
New creates a new QRSequence with the given data and chunk size.
Parameters: - data: a byte slice containing the data to be split into chunks. - chunkSize: a ChunkSize enum value specifying the size of each chunk.
Returns: - a pointer to a QRSequence object.
func NewEmpty ¶
func NewEmpty() *QRSequence
NewEmpty creates a new QRSequence with an unknown chunk size and an empty slice of QRChunks.
An empty sequence should be used to start decoding chunked qr images into the sequence.
Returns: - a pointer to a QRSequence object.
func (*QRSequence) AddChunkFromBytes ¶
func (s *QRSequence) AddChunkFromBytes(data []byte)
AddChunkFromBytes adds a chunk of data to the QRSequence.
It takes a byte slice as a parameter, which represents the data to be added. If the QRSequence is already complete, the function returns immediately. It creates a new chunk from the given data using the internal.NewChunk function. If the chunk is nil, the function returns. Otherwise, it adds the chunk to the QRSequence using the addChunk method.
func (QRSequence) Data ¶
func (s QRSequence) Data() []byte
Data returns the complete data of the QRSequence if it is complete, otherwise it returns nil.
Returns: - []byte: the data of the QRSequence if it is complete, otherwise nil.
func (*QRSequence) DecodeImage ¶
func (s *QRSequence) DecodeImage(img image.Image) error
DecodeImage decodes an image into a QRSequence.
It takes an image.Image as a parameter and attempts to decode it into a QRChunk. If the QRSequence is already complete, it returns nil. If the decoding is successful, the chunk is added to the QRSequence and nil is returned. If there is an error during decoding, the error is returned.
Parameters: - img: an image.Image to be decoded into a QRChunk.
Returns:
- error: an error if there was an issue decoding the image or if the QRSequence is already complete.
func (QRSequence) IsComplete ¶
func (s QRSequence) IsComplete() bool
IsComplete checks if the QRSequence is complete.
It returns true if all chunks of the sequence have been received, false otherwise.
Returns: - bool: true if the QRSequence is complete, false otherwise.
func (QRSequence) Progress ¶
func (s QRSequence) Progress() float32
Progress returns the progress of the QRSequence.
It calculates the progress as a float32 value between 0 and 1. If all chunks have been received, it returns 1. Otherwise, it calculates the progress by dividing the number of received chunks by the total number of chunks.
Returns: - float32: the progress of the QRSequence.
func (QRSequence) QRCodes ¶
func (s QRSequence) QRCodes(blockSize int) ([]image.Image, error)
QRCodes generates a slice of QR codes for each chunk in the QRSequence.
It takes an integer parameter `blockSize` which specifies the size of the QR code blocks.
Returns:
- []image.Image: a slice of QR codes generated for each chunk in the QRSequence.
- error: an error if the QRSequence is not complete or if there is an error while generating the QR codes.