stbimage 0.2.1 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dee6483bc900314ff5c02f734ebc3ddeadfeffa3e780ee564a54fc44008406d2
4
- data.tar.gz: e95ea2ba342e53eebdc9fb1b7390bb705f6cdc7f6993af69fca0b0a0363a3dbb
3
+ metadata.gz: 2bcd3ab3b0b48a77141fcca550db3b1a0c09e11d29e9773c9ac223886e971305
4
+ data.tar.gz: fe10826a06846cfa142957074c9fcf823007523d911ebbce5c1f6257d17bb75d
5
5
  SHA512:
6
- metadata.gz: c61cbd2a8e1084834aff19e41d7245e189251feef10829eab4a8bf3676b8b1224062e5a1a2978545e0b08bf32bec59efdd05f468a4f483cc5bfb016421684bff
7
- data.tar.gz: 01af2da836ff901fa79784779d3679920d82e84ef3fde5d9dc6d7aa2ec444516d8ea0f8a0c2d40d4e5b7836e27f803f624f91918ca749f5dd396f3e5109ac287
6
+ metadata.gz: ce225e878f58bae458104edeebff01eb714ee08c2453c67fdf0a23840790d2b2435f41dbe80e27421b97dda72e3b76855c24fabac68c0be56711b8ffb8ad8939
7
+ data.tar.gz: f11837adcbb954dff506566c4bd7845224768246907c375d6061a4eaa45ed6352ea91bd612ca9a2771cca9bd741126adb03bf423edac84a537e01144ee4ff89f
@@ -0,0 +1,116 @@
1
+ # STBIMAGE
2
+
3
+
4
+
5
+ Ruby binding of stb-image.h
6
+
7
+ **Works well on windows!!!**
8
+ **Added support for Linux (32, 64, arm)**
9
+
10
+ * ### Supports (so far): ###
11
+ <br>
12
+
13
+ * **stbi_load** (Default image loader)
14
+ * **stbi_load_16**
15
+ * **stbi_loadf** (For `.hdr` images)
16
+ * **stbi_info**
17
+ * **stbi_image_free**
18
+ * **stbi_failure_reason**
19
+ * **stbi_set_flip_vertically_on_load**
20
+ * **stbi_set_flip_vertically_on_load_thread**
21
+ * **stbi_set_unpremultiply_on_load**
22
+ * **stbi_convert_iphone_png_to_rgb**
23
+ * **stbi_hdr_to_ldr_gamma**
24
+ * **stbi_hdr_to_ldr_scale**
25
+ * **stbi_is_16_bit**
26
+ * **stbi_is_hdr**
27
+ * **stbi_zlib_decode_buffer**
28
+ * **stbi_zlib_decode_malloc**
29
+ * **stbi_zlib_decode_malloc_guesssize**
30
+ * **stbi_zlib_decode_malloc_guesssize_headerflag**
31
+ * **stbi_zlib_decode_noheader_buffer**
32
+ * **stbi_zlib_decode_noheader_malloc**
33
+
34
+
35
+ <br>
36
+
37
+ # Installation
38
+
39
+ * Windows:\
40
+ `gem install stbimage`
41
+
42
+ * Linux/macOs:\
43
+ `gem install stbimage`
44
+
45
+ *Note: In macOs you have to compile the dynamic libary (.so) yourself. Although I planned to include it in the future*
46
+
47
+ <br>
48
+
49
+ # .dll libs
50
+
51
+ You can find it under [dlls](dlls) folder
52
+
53
+ <br>
54
+
55
+ # Usage
56
+
57
+ ```ruby
58
+ require 'stbimage'
59
+
60
+ # use this to load the dll (from gem version 0.2.3 and above)! Only For windows and linux yet
61
+ STBIMAGE.load_lib()
62
+
63
+ # In macOs you have to provide a dynamic libary (.so) by yourself
64
+ # STBIMAGE.load_lib('your_name.so', 'absolute_path_to_file')
65
+
66
+
67
+ width = ' ' * 4
68
+ height = ' ' * 4
69
+ nr_channels = ' ' * 4
70
+
71
+ data = STBIMAGE.stbi_load("blue-poly.jpg", width, height, nr_channels, 0)
72
+
73
+ puts data # You can use this data in OpenGL for instance.
74
+
75
+ puts width.unpack('l')[0]
76
+ puts height.unpack('l')[0]
77
+ puts nr_channels.unpack('l')[0]
78
+ ```
79
+
80
+ <br>
81
+
82
+ # Credit
83
+
84
+ * Credit to Vaiorabbit who made the bindings of opengl into ruby! This wrapper is based on his glfw wrapper.
85
+ His repo: https://github.com/vaiorabbit/ruby-opengl
86
+
87
+ * stb_image.h by Sean Barret. Repo: https://github.com/nothings/stb/blob/master/stb_image.h
88
+
89
+
90
+ <br>
91
+
92
+ # Licence
93
+
94
+ MIT License
95
+
96
+ ```
97
+ Copyright (c) 2021 Samuel Keresztes
98
+
99
+ Permission is hereby granted, free of charge, to any person obtaining a copy
100
+ of this software and associated documentation files (the "Software"), to deal
101
+ in the Software without restriction, including without limitation the rights
102
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
103
+ copies of the Software, and to permit persons to whom the Software is
104
+ furnished to do so, subject to the following conditions:
105
+
106
+ The above copyright notice and this permission notice shall be included in all
107
+ copies or substantial portions of the Software.
108
+
109
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
110
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
111
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
112
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
113
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
114
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
115
+ SOFTWARE.
116
+ ```
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -29,20 +29,53 @@ 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
- if RUBY_PLATFORM == "x64-mswin64_140" || RUBY_PLATFORM == "x64-mingw32"
42
- lib, path = 'stbDLL_x64.dll', '../dlls'
43
- elsif RUBY_PLATFORM == "x86-mingw32"
44
- lib, path = 'stbDLL_x86.dll', '../dlls'
37
+
38
+ if RUBY_PLATFORM =~ /64/
39
+
40
+ # puts "You have a 64-bit Architecture ruby"
41
+ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
42
+ # puts "With Windows"
43
+ lib, path = 'stbDLL_x64.dll', "#{__dir__}/../dlls"
44
+ elsif RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /cygwin/
45
+ # puts "With Linux"
46
+ lib, path = 'libstb_x64.so', "#{__dir__}/../dlls"
47
+ elsif RUBY_PLATFORM =~ /darwin/
48
+ # puts "With macOS"
49
+ else
50
+ # puts "I have no idea what os are you using, so it's possible that stbimage wont't work"
51
+ end
52
+
53
+ elsif RUBY_PLATFORM =~ /arm/
54
+
55
+ # puts "You have a arm architecture"
56
+ lib, path = 'libstb_arm.so', "#{__dir__}/../dlls"
57
+
58
+ elsif RUBY_PLATFORM =~ /java/
59
+
60
+ # puts "You have jruby!"
61
+
62
+ else
63
+
64
+ # puts "You have a 32-bit Architecture ruby"
65
+ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
66
+ # puts "With Windows"
67
+ lib, path = 'stbDLL_x86.dll', "#{__dir__}/../dlls"
68
+ elsif RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /cygwin/
69
+ # puts "With Linux"
70
+ lib, path = 'libstb_x86.so', "#{__dir__}/../dlls"
71
+ elsif RUBY_PLATFORM =~ /darwin/
72
+ # puts "With macOS"
73
+ else
74
+ # puts "I have no idea what os are you using, so it's possible that stbimage wont't work"
75
+ end
76
+
45
77
  end
78
+
46
79
  end
47
80
 
48
81
  if path
@@ -50,31 +83,31 @@ Load native dll libary
50
83
  else
51
84
  dlload (lib)
52
85
  end
53
- import_symbols(output_error) unless @@glfw_import_done
86
+ import_symbols(output_error) unless @@stbi_image_import_done
54
87
  end
55
88
 
56
89
  @@lib_signature = [
57
90
  'void stbi_convert_iphone_png_to_rgb(int)',
58
- 'const char *stbi_failure_reason(void)',
91
+ 'const char* stbi_failure_reason(void)',
59
92
  'void stbi_hdr_to_ldr_gamma(float)',
60
93
  'void stbi_hdr_to_ldr_scale(float)',
61
94
  'void stbi_image_free(void*)',
62
95
  'int stbi_info(char const* , int*, int*, int*)',
63
- # 'int stbi_info_from_callbacks(stbi_io_callbacks const*, void*, int*, int*, comp*)'
96
+ # 'stbi_info_from_callbacks'
64
97
  # 'stbi_info_from_file'
65
98
  # 'stbi_info_from_memory'
66
- # 'stbi_is_16_bit'
99
+ 'int stbi_is_16_bit(char const*)',
67
100
  # 'stbi_is_16_bit_from_callbacks'
68
101
  # 'stbi_is_16_bit_from_file'
69
102
  # 'stbi_is_16_bit_from_memory'
70
- # 'stbi_is_hdr'
103
+ 'int stbi_is_hdr(char const*)',
71
104
  # 'stbi_is_hdr_from_callbacks'
72
105
  # 'stbi_is_hdr_from_file'
73
106
  # 'stbi_is_hdr_from_memory'
74
- # 'stbi_ldr_to_hdr_gamma'
75
- # 'stbi_ldr_to_hdr_scale'
107
+ 'void stbi_ldr_to_hdr_gamma(float)',
108
+ 'void stbi_ldr_to_hdr_scale(float)',
76
109
  'stbi_uc* stbi_load(char const*, int*, int*, int*, int)',
77
- # 'stbi_load_16'
110
+ 'stbi_us* stbi_load_16(char const*, int*, int*, int*, int)',
78
111
  # 'stbi_load_16_from_callbacks'
79
112
  # 'stbi_load_16_from_memory'
80
113
  # 'stbi_load_from_callbacks'
@@ -82,37 +115,38 @@ Load native dll libary
82
115
  # 'stbi_load_from_file_16'
83
116
  # 'stbi_load_from_memory'
84
117
  # 'stbi_load_gif_from_memory'
85
- # 'stbi_loadf'
118
+ 'float* stbi_loadf(char const*, int*, int*, int*, int)',
86
119
  # 'stbi_loadf_from_callbacks'
87
120
  # 'stbi_loadf_from_file'
88
121
  # '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'
122
+ 'void stbi_set_flip_vertically_on_load(int)',
123
+ 'void stbi_set_flip_vertically_on_load_thread(int)',
124
+ 'void stbi_set_unpremultiply_on_load(int)',
125
+ 'int stbi_zlib_decode_buffer(char*, int, const char*, int)',
126
+ 'char* stbi_zlib_decode_malloc(const char*, int, int*)',
127
+ 'char* stbi_zlib_decode_malloc_guesssize(const char*, int, int, int*)',
128
+ 'char* stbi_zlib_decode_malloc_guesssize_headerflag(const char*, int, int, int*, int)',
129
+ 'int stbi_zlib_decode_noheader_buffer(char*, int, const char*, int)',
130
+ 'char* stbi_zlib_decode_noheader_malloc(const char*, int, int*)'
131
+
98
132
  ]
99
133
 
100
134
  def self.import_symbols(output_error = false)
101
135
  typealias 'stbi_uc', 'unsigned char'
102
- typealias 'stbi_us', 'unsigned short'
103
-
136
+ typealias 'stbi_us', 'unsigned short'
104
137
 
105
138
  # function
106
139
  @@lib_signature.each do |sig|
140
+
107
141
  begin
108
142
  extern sig
109
143
  rescue
110
144
  $stderr.puts("[Warning] Failed to import #{sig}.") if output_error
111
145
  end
146
+
112
147
  end
113
148
 
114
- @@glfw_import_done = true
149
+ @@stbi_image_import_done = true
150
+
115
151
  end
116
-
117
- end
118
-
152
+ end
@@ -0,0 +1,51 @@
1
+ RUBY_PLATFORM = x86-mingw32
2
+
3
+ if RUBY_PLATFORM =~ /64/
4
+
5
+ puts "You have a 64-bit Architecture ruby"
6
+ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
7
+ puts "With Windows"
8
+ lib, path = 'stbDLL_x64.dll', "#{__dir__}/../dlls"
9
+ elsif RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /cygwin/
10
+ puts "With Linux"
11
+ lib, path = 'libstb_x64.so', "#{__dir__}/../dlls"
12
+ elsif RUBY_PLATFORM =~ /darwin/
13
+ puts "With macOS"
14
+ else
15
+ puts "I have no idea what os are you using, so it's possible that stbimage wont't work"
16
+ end
17
+
18
+ elsif RUBY_PLATFORM =~ /arm/
19
+
20
+ puts "You have a arm architecture"
21
+ lib, path = 'libstb_arm.so', "#{__dir__}/../dlls"
22
+
23
+ elsif RUBY_PLATFORM =~ /java/
24
+
25
+ puts "You have jruby!"
26
+
27
+ else
28
+
29
+ puts "You have a 32-bit Architecture ruby"
30
+ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
31
+ puts "With Windows"
32
+ lib, path = 'stbDLL_x32.dll', "#{__dir__}/../dlls"
33
+ elsif RUBY_PLATFORM =~ /linux/ || RUBY_PLATFORM =~ /cygwin/
34
+ puts "With Linux"
35
+ lib, path = 'libstb_x32.so', "#{__dir__}/../dlls"
36
+ elsif RUBY_PLATFORM =~ /darwin/
37
+ puts "With macOS"
38
+ else
39
+ puts "I have no idea what os are you using, so it's possible that stbimage wont't work"
40
+ end
41
+
42
+ end
43
+
44
+
45
+ # if RUBY_PLATFORM == "x64-mswin64_140" || RUBY_PLATFORM == "x64-mingw32"
46
+ # lib, path = 'stbDLL_x64.dll', "#{__dir__}/../dlls"
47
+ # elsif RUBY_PLATFORM == "x86-mingw32"
48
+ # lib, path = 'stbDLL_x86.dll', "#{__dir__}/../dlls"
49
+ # elsif RUBY_PLATFORM =~ /x86_linux/
50
+ # lib, path = 'libstd_x86.so', "#{__dir__}/../dlls"
51
+ # else
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.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Keresztes
@@ -10,15 +10,24 @@ 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(). Only works with windows so far!!!!!. PLEASE
15
- CHECK OUT THE HOMEPAGE FOR MORE INFO AND EXAMPLE"
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 (win32/win64) and
16
+ with linux so far, but for macOS, users have to include . Checkout the Homepage
17
+ for more info (installation, usage and other information)"
16
18
  email: ''
17
19
  executables: []
18
20
  extensions: []
19
21
  extra_rdoc_files: []
20
22
  files:
23
+ - README.md
24
+ - dlls/libstb_arm.so
25
+ - dlls/libstb_x64.so
26
+ - dlls/libstb_x86.so
27
+ - dlls/stbDLL_x64.dll
28
+ - dlls/stbDLL_x86.dll
21
29
  - lib/stbimage.rb
30
+ - utils/system_check.rb
22
31
  homepage: https://github.com/fellowchap-samuel/stbimage-ruby
23
32
  licenses:
24
33
  - MIT