add support for depth in barcode generations
- Introduced depth parameter to EncodeWithDepth function to allow generating barcodes with specified color depth. - Updated Encode function to use EncodeWithDepth with a default depth of 16.
This commit is contained in:
1 parent
f3630e1cd4
commit
87ab0677e3
15 files changed
+114
-47
No files matched your search
+8
-4
@@ -74,9 +74,7 @@ func prepare(content string) (string, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Encode returns a code93 barcode for the given content
|
||||
// if includeChecksum is set to true, two checksum characters are calculated and added to the content
|
||||
func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.Barcode, error) {
|
||||
func EncodeWithDepth(content string, includeChecksum bool, fullASCIIMode bool, depth int) (barcode.Barcode, error) {
|
||||
if fullASCIIMode {
|
||||
var err error
|
||||
content, err = prepare(content)
|
||||
@@ -104,7 +102,13 @@ func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.B
|
||||
}
|
||||
result.AddBit(true)
|
||||
|
||||
return utils.New1DCode(barcode.TypeCode93, content, result), nil
|
||||
return utils.New1DCodeWithDepth(barcode.TypeCode93, content, result, depth), nil
|
||||
}
|
||||
|
||||
// Encode returns a code93 barcode for the given content
|
||||
// if includeChecksum is set to true, two checksum characters are calculated and added to the content
|
||||
func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.Barcode, error) {
|
||||
return EncodeWithDepth(content, includeChecksum, fullASCIIMode, 16)
|
||||
}
|
||||
|
||||
func getChecksum(content string, maxWeight int) rune {
|
||||
|
||||
Reference in new issue
Block a user