cheetah_qrcode 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/cheetah_qrcode/cheetah_qrcode.c +26 -3
- data/lib/cheetah_qrcode/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b29d21d21eec28473d59567fa25267c61c18ad20192833cd31f9bbe415b5ff99
|
4
|
+
data.tar.gz: 49baa7dcb9bae3524c6a179d6857e8d004a3056695bbd2586928396222b1e643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 177e1343d936bf964a5bc3d83cade60e618b1d6e2d16fa980950977095c83a964c85edd13ab0bc1357da71e427cc18014882bd5f813c5dd0771e9c90be940dfc
|
7
|
+
data.tar.gz: 770a535c33374561f6a3d4133bd68871bcb0224c7796aba15cfc6464a1e159ae71ffd20ebd1c4aed6118cf5eb72cfc312604ebb2955e84a2d3e7405653732b3a
|
@@ -113,6 +113,14 @@ static VALUE encode_text(int argc, VALUE* argv, VALUE self) {
|
|
113
113
|
size_t iy_begin = (size_t)(qy * image_scale) + 1;
|
114
114
|
size_t iy_end = (size_t)((qy + 1) * image_scale) + 1;
|
115
115
|
|
116
|
+
// Fix offset for the first pixel
|
117
|
+
if (qx == 0) {
|
118
|
+
ix_begin = 0;
|
119
|
+
}
|
120
|
+
if (qy == 0) {
|
121
|
+
iy_begin = 0;
|
122
|
+
}
|
123
|
+
|
116
124
|
// For boundary safety
|
117
125
|
if (ix_end > image_size) {
|
118
126
|
ix_end = image_size;
|
@@ -121,12 +129,27 @@ static VALUE encode_text(int argc, VALUE* argv, VALUE self) {
|
|
121
129
|
iy_end = image_size;
|
122
130
|
}
|
123
131
|
|
124
|
-
// Fill white pixels into image
|
132
|
+
// Fill white pixels into image at unit of bytes
|
125
133
|
for (size_t iy = iy_begin; iy < iy_end; iy++) {
|
126
|
-
|
134
|
+
size_t ix = ix_begin;
|
135
|
+
size_t ix_diff = ix_end - ix_begin;
|
136
|
+
|
137
|
+
while (ix_diff > 0) {
|
127
138
|
size_t i = (iy * image_scanline_width) + (ix / 8);
|
128
139
|
|
129
|
-
|
140
|
+
uint8_t byte_value = 0xFF;
|
141
|
+
uint8_t bits_needed = 8 - (ix % 8);
|
142
|
+
|
143
|
+
if (bits_needed > ix_diff) {
|
144
|
+
byte_value <<= (bits_needed - ix_diff);
|
145
|
+
bits_needed = ix_diff;
|
146
|
+
}
|
147
|
+
|
148
|
+
byte_value >>= (ix % 8);
|
149
|
+
image[i] |= byte_value;
|
150
|
+
|
151
|
+
ix += bits_needed;
|
152
|
+
ix_diff -= bits_needed;
|
130
153
|
}
|
131
154
|
}
|
132
155
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheetah_qrcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- atitan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- ext/cheetah_qrcode/spng.h
|
55
55
|
- lib/cheetah_qrcode.rb
|
56
56
|
- lib/cheetah_qrcode/version.rb
|
57
|
-
homepage:
|
57
|
+
homepage: https://github.com/atitan/cheetah_qrcode
|
58
58
|
licenses:
|
59
59
|
- MIT
|
60
60
|
metadata: {}
|