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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ecaba6d7978240dfaff4ce078906437b8d212ea39dcb3271d3fa08e44851b55
4
- data.tar.gz: 60ce766b66cf9c5a1e414a0fd5297c3ba004d8463102b7aa42faece93976ddcc
3
+ metadata.gz: d2023bcfafa01c196edc300988fe9e3d50a6a002daafc22874cca6a2b4fa620d
4
+ data.tar.gz: 9f3d39259f1e39a5cf2c111101a4aabe06bb5e2bba401fb76bf849a2f8c9d58b
5
5
  SHA512:
6
- metadata.gz: 8c06e3ec464428ac7b6d0910e14d80ca0b6648731449b6d3360e66f5da167ecfc60b6e6f57e98d5c1868f3f7a0dcd3db0e21e5d513dcb638902ac93a5dbb60f3
7
- data.tar.gz: a807d6e2e3cd31c0de78aa7caf2e46ec755f80c08b9664e97be39ee66e187adc3fdb8eedf638b0049d94358289b92c7bb8722eb386c4e54cca4bf5c061ec6c32
6
+ metadata.gz: c0f11f6fec0dc2f4829becbd81c8b3b4738ba480d3ccce05f109ef485bfd892706fdfa8f75a60a0c04c975dc2502b81dc6fd8366b0d90187cf5563f4ba111ad9
7
+ data.tar.gz: a337245802d6e0419788ffceb67a3aa293c59d9c7fdb5174205d43eebf1b16f2dd3ff659dda89c6ba151caf7be0449d680425a93a69e704ac34aedd403026306
@@ -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 *data = zbar_image_get_data(img);
14
- if (data) free((void *)data);
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 *width, int *height) {
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 *img = stbi_load(image_path, width, height, &channels, 0);
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 *gray = malloc(pixels);
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 *decoded_string = "";
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 *image_path_ptr = StringValuePtr(image_path);
78
+ const char* image_path_ptr = StringValuePtr(image_path);
80
79
  int width, height;
81
- unsigned char *img = load_image(image_path_ptr, &width, &height);
82
- if (!img) {
83
- rb_raise(qrscan_error, "Error loading image");
84
- }
85
- const char* s = scan_image(img, width, height);
86
- return rb_str_new2(s);
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() {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qrscan
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.0
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-27 00:00:00.000000000 Z
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
Binary file