stbimage 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +87 -18
  3. data/lib/stbimage.rb +30 -30
  4. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32f96cdeb03fd88a7e4b6d29158af7d6ae1a646001b01914d8159d98b1765528
4
- data.tar.gz: 1e02ba30e6eace68f587b89914109aa379fe1361830bde57af79a7fdb4c37892
3
+ metadata.gz: db813db9f8656c1b4e4ab644d47f97c561bcca2099ef6983ade9bc28a16f5579
4
+ data.tar.gz: 5668270ce32c8305e358cc35626c810fd58a69094b67be24c2afe67858e133ec
5
5
  SHA512:
6
- metadata.gz: 5ac1c2781afdd7561d3d890af931a89360db9cc4cdf09ac0754cde72ffb328bd400f44f5b4b39eb5aefdb5dffeb0cb7b421cf0e7e33246f05bcb5eb7ce2a72ea
7
- data.tar.gz: c8591f92dfbf67d77a77e6b3980392133a894f6c700d9a9e61c16842cc11571929234afda38e2afe0ee0172bcfcb1d24ec9e4e3d285a93d388d8a17e91c4a2ce
6
+ metadata.gz: 3ffab71c7a5bb8f28af4c67b0fd3add92a031f74b36a2c5d0aa24d587996ea7bc93d166b812215fcf6ac87965358f483c2c5ac7ecea9ecc13bb239f22302d90a
7
+ data.tar.gz: 26a238c2444b93a137b720fac42b0cdf6c0780120b0c3870f3d63a179d1e47d99f111c8b72867e2ce484a9f11a55e5d8b0fa699c016784b10ff8a2d149a0709f
data/README.md CHANGED
@@ -1,31 +1,67 @@
1
- # stbimage-ruby
2
- Binding of stb-image into the ruby programing language.
1
+ # STBIMAGE
3
2
 
4
- # Tutorials
5
3
 
6
- 1. To use this gem first install it with:
4
+
5
+ Ruby binding of stb-image.h
6
+
7
+ **Works well on windows!!!**
8
+
9
+ * ### Supports (so far): ###
10
+ <br>
11
+
12
+ * **stbi_load** (Default image loader)
13
+ * **stbi_load_16**
14
+ * **stbi_loadf** (For `.hdr` images)
15
+ * **stbi_info**
16
+ * **stbi_image_free**
17
+ * **stbi_failure_reason**
18
+ * **stbi_set_flip_vertically_on_load**
19
+ * **stbi_set_flip_vertically_on_load_thread**
20
+ * **stbi_set_unpremultiply_on_load**
21
+ * **stbi_convert_iphone_png_to_rgb**
22
+ * **stbi_hdr_to_ldr_gamma**
23
+ * **stbi_hdr_to_ldr_scale**
24
+ * **stbi_is_16_bit**
25
+ * **stbi_is_hdr**
26
+ * **stbi_zlib_decode_buffer**
27
+ * **stbi_zlib_decode_malloc**
28
+ * **stbi_zlib_decode_malloc_guesssize**
29
+ * **stbi_zlib_decode_malloc_guesssize_headerflag**
30
+ * **stbi_zlib_decode_noheader_buffer**
31
+ * **stbi_zlib_decode_noheader_malloc**
32
+
33
+
34
+ <br>
35
+
36
+ # Installation
37
+
38
+ * Windows:\
7
39
  `gem install stbimage`
8
- 2. Require it in your project with\
9
- `require 'stbimage'`
10
- 3. Load your dll dynamic libary what is in your projects root folder!!! (Download the dlls: visit my webpage.)\
11
- `STBIMAGE.load_lib()`
12
- 4. Then you can use it :D
13
40
 
14
- # About the dll libs
41
+ * Linux/macOs:\
42
+ `gem install stbimage`
43
+
44
+ *Note: In Linux/macOs you have to compile the dynamic libary (.so) yourself. Although I planned to include it in the future*
45
+
46
+ <br>
47
+
48
+ # .dll libs
15
49
 
16
50
  You can find it under [dlls](dlls) folder
17
51
 
18
- # A full Example:
52
+ <br>
53
+
54
+ # Usage
19
55
 
20
56
  ```ruby
21
- require 'stb_image'
57
+ require 'stbimage'
22
58
 
23
- # Note that you need to name your dll file to stbDLL.dll in this case
59
+ # use this to load the dll (from gem version 0.2.3 and above)! Only For windows yet
24
60
  STBIMAGE.load_lib()
25
- # Or if you want to specify another name for it, use:
26
- # STBIMAGE.load_lib('your_name.dll')
27
61
 
28
- # But don't forget that ruby searches your dll file in your current directory!
62
+ # In linux and macOs you have to provide a dynamic libary (.so)
63
+ # STBIMAGE.load_lib('your_name.so', 'absolute_path_to_file')
64
+
29
65
 
30
66
  width = ' ' * 4
31
67
  height = ' ' * 4
@@ -33,14 +69,47 @@ nr_channels = ' ' * 4
33
69
 
34
70
  data = STBIMAGE.stbi_load("blue-poly.jpg", width, height, nr_channels, 0)
35
71
 
36
- puts data
72
+ puts data # You can use this data in OpenGL for instance.
37
73
 
38
74
  puts width.unpack('l')[0]
39
75
  puts height.unpack('l')[0]
40
76
  puts nr_channels.unpack('l')[0]
41
77
  ```
42
78
 
79
+ <br>
80
+
43
81
  # Credit
44
82
 
45
- Credit to Vaiorabbit who made the bindings of opengl into ruby! This wrapper is based on his glfw wrapper. :D \
83
+ * Credit to Vaiorabbit who made the bindings of opengl into ruby! This wrapper is based on his glfw wrapper.
46
84
  His repo: https://github.com/vaiorabbit/ruby-opengl
85
+
86
+ * stb_image.h by Sean Barret. Repo: https://github.com/nothings/stb/blob/master/stb_image.h
87
+
88
+
89
+ <br>
90
+
91
+ # Licence
92
+
93
+ MIT License
94
+
95
+ ```
96
+ Copyright (c) 2021 Samuel Keresztes
97
+
98
+ Permission is hereby granted, free of charge, to any person obtaining a copy
99
+ of this software and associated documentation files (the "Software"), to deal
100
+ in the Software without restriction, including without limitation the rights
101
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
102
+ copies of the Software, and to permit persons to whom the Software is
103
+ furnished to do so, subject to the following conditions:
104
+
105
+ The above copyright notice and this permission notice shall be included in all
106
+ copies or substantial portions of the Software.
107
+
108
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
109
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
110
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
111
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
112
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
113
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
114
+ SOFTWARE.
115
+ ```
@@ -29,19 +29,18 @@ module STBIMAGE
29
29
  end
30
30
 
31
31
 
32
- @@glfw_import_done = false
32
+ @@stbi_image_import_done = false
33
33
 
34
- =begin
35
- Load native dll libary
36
- - lib = the name of the file
37
- - path = route to the file
38
- =end
34
+ # Load native dll libary
39
35
  def self.load_lib(lib = nil, path = nil, output_error = false)
40
36
  if lib == nil && path == nil
41
37
  if RUBY_PLATFORM == "x64-mswin64_140" || RUBY_PLATFORM == "x64-mingw32"
42
38
  lib, path = 'stbDLL_x64.dll', "#{__dir__}/../dlls"
43
39
  elsif RUBY_PLATFORM == "x86-mingw32"
44
40
  lib, path = 'stbDLL_x86.dll', "#{__dir__}/../dlls"
41
+ # elsif RUBY_PLATFORM == ""
42
+ else
43
+
45
44
  end
46
45
  end
47
46
 
@@ -50,31 +49,31 @@ Load native dll libary
50
49
  else
51
50
  dlload (lib)
52
51
  end
53
- import_symbols(output_error) unless @@glfw_import_done
52
+ import_symbols(output_error) unless @@stbi_image_import_done
54
53
  end
55
54
 
56
55
  @@lib_signature = [
57
56
  'void stbi_convert_iphone_png_to_rgb(int)',
58
- 'const char *stbi_failure_reason(void)',
57
+ 'const char* stbi_failure_reason(void)',
59
58
  'void stbi_hdr_to_ldr_gamma(float)',
60
59
  'void stbi_hdr_to_ldr_scale(float)',
61
60
  'void stbi_image_free(void*)',
62
61
  'int stbi_info(char const* , int*, int*, int*)',
63
- # 'int stbi_info_from_callbacks(stbi_io_callbacks const*, void*, int*, int*, comp*)'
62
+ # 'stbi_info_from_callbacks'
64
63
  # 'stbi_info_from_file'
65
64
  # 'stbi_info_from_memory'
66
- # 'stbi_is_16_bit'
65
+ 'int stbi_is_16_bit(char const*)',
67
66
  # 'stbi_is_16_bit_from_callbacks'
68
67
  # 'stbi_is_16_bit_from_file'
69
68
  # 'stbi_is_16_bit_from_memory'
70
- # 'stbi_is_hdr'
69
+ 'int stbi_is_hdr(char const*)',
71
70
  # 'stbi_is_hdr_from_callbacks'
72
71
  # 'stbi_is_hdr_from_file'
73
72
  # 'stbi_is_hdr_from_memory'
74
- # 'stbi_ldr_to_hdr_gamma'
75
- # 'stbi_ldr_to_hdr_scale'
73
+ 'void stbi_ldr_to_hdr_gamma(float)',
74
+ 'void stbi_ldr_to_hdr_scale(float)',
76
75
  'stbi_uc* stbi_load(char const*, int*, int*, int*, int)',
77
- # 'stbi_load_16'
76
+ 'stbi_us* stbi_load_16(char const*, int*, int*, int*, int)',
78
77
  # 'stbi_load_16_from_callbacks'
79
78
  # 'stbi_load_16_from_memory'
80
79
  # 'stbi_load_from_callbacks'
@@ -82,37 +81,38 @@ Load native dll libary
82
81
  # 'stbi_load_from_file_16'
83
82
  # 'stbi_load_from_memory'
84
83
  # 'stbi_load_gif_from_memory'
85
- # 'stbi_loadf'
84
+ 'float* stbi_loadf(char const*, int*, int*, int*, int)',
86
85
  # 'stbi_loadf_from_callbacks'
87
86
  # 'stbi_loadf_from_file'
88
87
  # 'stbi_loadf_from_memory'
89
- 'void stbi_set_flip_vertically_on_load(int)'
90
- # 'stbi_set_flip_vertically_on_load_thread'
91
- # 'stbi_set_unpremultiply_on_load'
92
- # 'stbi_zlib_decode_buffer'
93
- # 'stbi_zlib_decode_malloc'
94
- # 'stbi_zlib_decode_malloc_guesssize'
95
- # 'stbi_zlib_decode_malloc_guesssize_headerflag'
96
- # 'stbi_zlib_decode_noheader_buffer'
97
- # 'stbi_zlib_decode_noheader_malloc'
88
+ 'void stbi_set_flip_vertically_on_load(int)',
89
+ 'void stbi_set_flip_vertically_on_load_thread(int)',
90
+ 'void stbi_set_unpremultiply_on_load(int)',
91
+ 'int stbi_zlib_decode_buffer(char*, int, const char*, int)',
92
+ 'char* stbi_zlib_decode_malloc(const char*, int, int*)',
93
+ 'char* stbi_zlib_decode_malloc_guesssize(const char*, int, int, int*)',
94
+ 'char* stbi_zlib_decode_malloc_guesssize_headerflag(const char*, int, int, int*, int)',
95
+ 'int stbi_zlib_decode_noheader_buffer(char*, int, const char*, int)',
96
+ 'char* stbi_zlib_decode_noheader_malloc(const char*, int, int*)'
97
+
98
98
  ]
99
99
 
100
100
  def self.import_symbols(output_error = false)
101
101
  typealias 'stbi_uc', 'unsigned char'
102
- typealias 'stbi_us', 'unsigned short'
103
-
102
+ typealias 'stbi_us', 'unsigned short'
104
103
 
105
104
  # function
106
105
  @@lib_signature.each do |sig|
106
+
107
107
  begin
108
108
  extern sig
109
109
  rescue
110
110
  $stderr.puts("[Warning] Failed to import #{sig}.") if output_error
111
111
  end
112
+
112
113
  end
113
114
 
114
- @@glfw_import_done = true
115
+ @@stbi_image_import_done = true
116
+
115
117
  end
116
-
117
- end
118
-
118
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stbimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Keresztes
@@ -10,11 +10,11 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-01-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: "!Beta Version! Will be developed! So far compatible with: stbi_load,
14
- stbi_set_flip_vertically_on_load(). \n Only works with windows so far!!!!! (win32/win64).
15
- PLEASE CHECK OUT THE HOMEPAGE FOR MORE INFO AND EXAMPLE. With 0.2.3 and above dlls
16
- are included so 'STBIMAGE.load_lib()'\n should be enough for linking shared liaries.
17
- So it's worth to upgrade 0.2.3! "
13
+ description: "!Beta Version! A practical image importer/loader. It wraps stb_image.h
14
+ (ver:2.26 -2020.07.13-). Supported image formats are: JPEG, PNG, TGA, BMP, PSD,
15
+ GIF(not animation), HDR, PIC, PNM. Only works well with windows so far (win32/win64),
16
+ but linux/macOs users also can use it. Checkout the Homepage for more info (installation,
17
+ usage and other information)"
18
18
  email: ''
19
19
  executables: []
20
20
  extensions: []