qrscan 0.1.0 → 0.1.1
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/qrscan/extconf.rb +2 -0
- data/ext/qrscan/qrscan.c +15 -14
- data/lib/qrscan/version.rb +1 -1
- metadata +2 -3
- data/ext/qrscan/qr_scanner.o +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2023bcfafa01c196edc300988fe9e3d50a6a002daafc22874cca6a2b4fa620d
|
4
|
+
data.tar.gz: 9f3d39259f1e39a5cf2c111101a4aabe06bb5e2bba401fb76bf849a2f8c9d58b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0f11f6fec0dc2f4829becbd81c8b3b4738ba480d3ccce05f109ef485bfd892706fdfa8f75a60a0c04c975dc2502b81dc6fd8366b0d90187cf5563f4ba111ad9
|
7
|
+
data.tar.gz: a337245802d6e0419788ffceb67a3aa293c59d9c7fdb5174205d43eebf1b16f2dd3ff659dda89c6ba151caf7be0449d680425a93a69e704ac34aedd403026306
|
data/ext/qrscan/extconf.rb
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
require "mkmf"
|
5
5
|
|
6
6
|
dir_config("qrscan", "/opt/homebrew/include", "/opt/homebrew/lib")
|
7
|
+
dir_config("qrscan", "C:/Program Files/ZBar/include", "C:/Program Files/ZBar/lib")
|
8
|
+
dir_config("qrscan", "C:/Program Files (x86)/ZBar/include", "C:/Program Files (x86)/ZBar/lib")
|
7
9
|
|
8
10
|
# Verifica la presenza dell'header e della libreria (opzionale)
|
9
11
|
have_header("zbar.h") or abort "zbar.h not found"
|
data/ext/qrscan/qrscan.c
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
#include "ruby.h"
|
2
2
|
|
3
|
-
#include <stdio.h>
|
4
3
|
#include <stdlib.h>
|
5
4
|
#include <string.h>
|
6
5
|
#include <zbar.h>
|
@@ -10,20 +9,20 @@
|
|
10
9
|
|
11
10
|
// Cleanup handler for the image data
|
12
11
|
void free_image(zbar_image_t *img) {
|
13
|
-
const void
|
14
|
-
if (data) free((void
|
12
|
+
const void* data = zbar_image_get_data(img);
|
13
|
+
if (data) free((void*)data);
|
15
14
|
}
|
16
15
|
|
17
|
-
unsigned char* load_image(const char* image_path, int
|
16
|
+
unsigned char* load_image(const char* image_path, int* width, int* height) {
|
18
17
|
int channels;
|
19
18
|
// Load image using stb_image
|
20
|
-
unsigned char
|
19
|
+
unsigned char* img = stbi_load(image_path, width, height, &channels, 0);
|
21
20
|
if (!img) {
|
22
21
|
return NULL;
|
23
22
|
}
|
24
23
|
int pixels = (*width) * (*height);
|
25
24
|
// Convert image to grayscale
|
26
|
-
unsigned char
|
25
|
+
unsigned char* gray = malloc(pixels);
|
27
26
|
if (!gray) {
|
28
27
|
stbi_image_free(img);
|
29
28
|
return NULL;
|
@@ -46,7 +45,7 @@ unsigned char* load_image(const char* image_path, int *width, int *height) {
|
|
46
45
|
}
|
47
46
|
|
48
47
|
const char* scan_image(unsigned char* image, int width, int height) {
|
49
|
-
const char
|
48
|
+
const char* decoded_string = NULL;
|
50
49
|
// Initialize zbar image scanner
|
51
50
|
zbar_image_scanner_t *scanner = zbar_image_scanner_create();
|
52
51
|
// Enable all barcode types
|
@@ -76,14 +75,16 @@ const char* scan_image(unsigned char* image, int width, int height) {
|
|
76
75
|
VALUE qrscan_error;
|
77
76
|
|
78
77
|
VALUE scan(VALUE self, VALUE image_path) {
|
79
|
-
const char
|
78
|
+
const char* image_path_ptr = StringValuePtr(image_path);
|
80
79
|
int width, height;
|
81
|
-
unsigned char
|
82
|
-
if (!
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
unsigned char* image = load_image(image_path_ptr, &width, &height);
|
81
|
+
if (!image) rb_raise(qrscan_error, "Error loading image");
|
82
|
+
|
83
|
+
const char* s = scan_image(image, width, height);
|
84
|
+
if (s)
|
85
|
+
return rb_str_new2(s);
|
86
|
+
else
|
87
|
+
return Qnil;
|
87
88
|
}
|
88
89
|
|
89
90
|
void Init_qrscan() {
|
data/lib/qrscan/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qrscan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pioz
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: A Ruby gem for decoding QR code from images.
|
13
13
|
email:
|
@@ -22,7 +22,6 @@ files:
|
|
22
22
|
- README.md
|
23
23
|
- Rakefile
|
24
24
|
- ext/qrscan/extconf.rb
|
25
|
-
- ext/qrscan/qr_scanner.o
|
26
25
|
- ext/qrscan/qrscan.c
|
27
26
|
- ext/qrscan/stb_image.h
|
28
27
|
- lib/qrscan.rb
|
data/ext/qrscan/qr_scanner.o
DELETED
Binary file
|