fixed various bugs with encoding qrcodes

This commit is contained in:
Henry Schimke
2023-01-08 15:34:00 -06:00
parent caaf4c2fe0
commit 104e66c410
3 changed files with 18 additions and 3 deletions

View File

@@ -19,6 +19,7 @@
* *
* @author qwandor@google.com (Andrew Walbran) * @author qwandor@google.com (Andrew Walbran)
*/ */
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dimensions { pub struct Dimensions {
minCols: usize, minCols: usize,
maxCols: usize, maxCols: usize,

View File

@@ -19,7 +19,8 @@ use std::{collections::HashMap, path::PathBuf};
use image::DynamicImage; use image::DynamicImage;
use crate::{ use crate::{
common::BitMatrix, qrcode::QRCodeWriter, BarcodeFormat, EncodeHintType, EncodeHintValue, Writer, common::BitMatrix, qrcode::QRCodeWriter, BarcodeFormat, DecodeHintType, DecodeHintValue,
EncodeHintType, EncodeHintValue, Writer,
}; };
use super::decoder::ErrorCorrectionLevel; use super::decoder::ErrorCorrectionLevel;

View File

@@ -1052,7 +1052,14 @@ impl RXingResultNode {
.encode_string( .encode_string(
// &self.stringToEncode[self.fromPosition as usize // &self.stringToEncode[self.fromPosition as usize
// ..(self.fromPosition + self.characterLength as usize)], // ..(self.fromPosition + self.characterLength as usize)],
self.stringToEncode.get(self.fromPosition).unwrap(), // self.stringToEncode.get(self.fromPosition).unwrap(),
&(self
.stringToEncode
.iter()
.skip(self.fromPosition)
.take(self.characterLength as usize)
.map(|s| s.as_str())
.collect::<String>()),
self.charsetEncoderIndex, self.charsetEncoderIndex,
) )
.len() as u32 .len() as u32
@@ -1080,7 +1087,13 @@ impl RXingResultNode {
encoder::appendBytes( encoder::appendBytes(
// &self.stringToEncode[self.fromPosition as usize // &self.stringToEncode[self.fromPosition as usize
// ..(self.fromPosition + self.characterLength as usize)], // ..(self.fromPosition + self.characterLength as usize)],
self.stringToEncode.get(self.fromPosition).unwrap(), &(self
.stringToEncode
.iter()
.skip(self.fromPosition)
.take(self.characterLength as usize)
.map(|s| s.as_str())
.collect::<String>()), //self.stringToEncode.get(self.fromPosition).unwrap(),
self.mode, self.mode,
bits, bits,
self.encoders.getCharset(self.charsetEncoderIndex), self.encoders.getCharset(self.charsetEncoderIndex),