stbimage 0.1.1 → 0.3.0

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: 35ba9c234353f12e550a8e9b4188f3d95174b0cdeddfb74aa1c86443854fbe83
4
- data.tar.gz: 76cdeba9b5a3b80e323e083ddb3faa718f59e086b4cd5487a76ea3e6d19dacc7
3
+ metadata.gz: db813db9f8656c1b4e4ab644d47f97c561bcca2099ef6983ade9bc28a16f5579
4
+ data.tar.gz: 5668270ce32c8305e358cc35626c810fd58a69094b67be24c2afe67858e133ec
5
5
  SHA512:
6
- metadata.gz: fa0da420b22e4d284bd4a586ab787534ca9b9335b2378cd4fcff84bfe4b97199bce7dbf13e5d8e7f03bb6ee0e24f9c0f37750b06222e05d8af542d2dbad41823
7
- data.tar.gz: df9b3a18b7e6ffef3c11a415b0b0c0e0934a6fe59054afb08f575efc30b56c213d08e017173ddd5804a287df32709595afd449c17ab63340f1fb5b550b17bb5b
6
+ metadata.gz: 3ffab71c7a5bb8f28af4c67b0fd3add92a031f74b36a2c5d0aa24d587996ea7bc93d166b812215fcf6ac87965358f483c2c5ac7ecea9ecc13bb239f22302d90a
7
+ data.tar.gz: 26a238c2444b93a137b720fac42b0cdf6c0780120b0c3870f3d63a179d1e47d99f111c8b72867e2ce484a9f11a55e5d8b0fa699c016784b10ff8a2d149a0709f
@@ -0,0 +1,115 @@
1
+ # STBIMAGE
2
+
3
+
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:\
39
+ `gem install stbimage`
40
+
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
49
+
50
+ You can find it under [dlls](dlls) folder
51
+
52
+ <br>
53
+
54
+ # Usage
55
+
56
+ ```ruby
57
+ require 'stbimage'
58
+
59
+ # use this to load the dll (from gem version 0.2.3 and above)! Only For windows yet
60
+ STBIMAGE.load_lib()
61
+
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
+
65
+
66
+ width = ' ' * 4
67
+ height = ' ' * 4
68
+ nr_channels = ' ' * 4
69
+
70
+ data = STBIMAGE.stbi_load("blue-poly.jpg", width, height, nr_channels, 0)
71
+
72
+ puts data # You can use this data in OpenGL for instance.
73
+
74
+ puts width.unpack('l')[0]
75
+ puts height.unpack('l')[0]
76
+ puts nr_channels.unpack('l')[0]
77
+ ```
78
+
79
+ <br>
80
+
81
+ # Credit
82
+
83
+ * Credit to Vaiorabbit who made the bindings of opengl into ruby! This wrapper is based on his glfw wrapper.
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
+ ```
Binary file
Binary file
@@ -29,12 +29,19 @@ module STBIMAGE
29
29
  end
30
30
 
31
31
 
32
- @@glfw_import_done = false
32
+ @@stbi_image_import_done = false
33
33
 
34
- # Load native library.
34
+ # Load native dll libary
35
35
  def self.load_lib(lib = nil, path = nil, output_error = false)
36
36
  if lib == nil && path == nil
37
- lib, path = 'stbDLL.dll', Dir.pwd
37
+ if RUBY_PLATFORM == "x64-mswin64_140" || RUBY_PLATFORM == "x64-mingw32"
38
+ lib, path = 'stbDLL_x64.dll', "#{__dir__}/../dlls"
39
+ elsif RUBY_PLATFORM == "x86-mingw32"
40
+ lib, path = 'stbDLL_x86.dll', "#{__dir__}/../dlls"
41
+ # elsif RUBY_PLATFORM == ""
42
+ else
43
+
44
+ end
38
45
  end
39
46
 
40
47
  if path
@@ -42,36 +49,31 @@ module STBIMAGE
42
49
  else
43
50
  dlload (lib)
44
51
  end
45
- import_symbols(output_error) unless @@glfw_import_done
46
- end
47
-
48
- def self.load_dll(lib = nil, path = nil)
49
- puts "Warning STBIMAGE.load_dll is deprecated, use GLFW.load_lib instead"
50
- self.load_lib(lib, path)
52
+ import_symbols(output_error) unless @@stbi_image_import_done
51
53
  end
52
54
 
53
55
  @@lib_signature = [
54
56
  'void stbi_convert_iphone_png_to_rgb(int)',
55
- 'const char *stbi_failure_reason(void)',
57
+ 'const char* stbi_failure_reason(void)',
56
58
  'void stbi_hdr_to_ldr_gamma(float)',
57
59
  'void stbi_hdr_to_ldr_scale(float)',
58
60
  'void stbi_image_free(void*)',
59
61
  'int stbi_info(char const* , int*, int*, int*)',
60
- # 'int stbi_info_from_callbacks(stbi_io_callbacks const*, void*, int*, int*, comp*)'
62
+ # 'stbi_info_from_callbacks'
61
63
  # 'stbi_info_from_file'
62
64
  # 'stbi_info_from_memory'
63
- # 'stbi_is_16_bit'
65
+ 'int stbi_is_16_bit(char const*)',
64
66
  # 'stbi_is_16_bit_from_callbacks'
65
67
  # 'stbi_is_16_bit_from_file'
66
68
  # 'stbi_is_16_bit_from_memory'
67
- # 'stbi_is_hdr'
69
+ 'int stbi_is_hdr(char const*)',
68
70
  # 'stbi_is_hdr_from_callbacks'
69
71
  # 'stbi_is_hdr_from_file'
70
72
  # 'stbi_is_hdr_from_memory'
71
- # 'stbi_ldr_to_hdr_gamma'
72
- # 'stbi_ldr_to_hdr_scale'
73
+ 'void stbi_ldr_to_hdr_gamma(float)',
74
+ 'void stbi_ldr_to_hdr_scale(float)',
73
75
  'stbi_uc* stbi_load(char const*, int*, int*, int*, int)',
74
- # 'stbi_load_16'
76
+ 'stbi_us* stbi_load_16(char const*, int*, int*, int*, int)',
75
77
  # 'stbi_load_16_from_callbacks'
76
78
  # 'stbi_load_16_from_memory'
77
79
  # 'stbi_load_from_callbacks'
@@ -79,37 +81,38 @@ module STBIMAGE
79
81
  # 'stbi_load_from_file_16'
80
82
  # 'stbi_load_from_memory'
81
83
  # 'stbi_load_gif_from_memory'
82
- # 'stbi_loadf'
84
+ 'float* stbi_loadf(char const*, int*, int*, int*, int)',
83
85
  # 'stbi_loadf_from_callbacks'
84
86
  # 'stbi_loadf_from_file'
85
87
  # 'stbi_loadf_from_memory'
86
- 'void stbi_set_flip_vertically_on_load(int)'
87
- # 'stbi_set_flip_vertically_on_load_thread'
88
- # 'stbi_set_unpremultiply_on_load'
89
- # 'stbi_zlib_decode_buffer'
90
- # 'stbi_zlib_decode_malloc'
91
- # 'stbi_zlib_decode_malloc_guesssize'
92
- # 'stbi_zlib_decode_malloc_guesssize_headerflag'
93
- # 'stbi_zlib_decode_noheader_buffer'
94
- # '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
+
95
98
  ]
96
99
 
97
100
  def self.import_symbols(output_error = false)
98
101
  typealias 'stbi_uc', 'unsigned char'
99
- typealias 'stbi_us', 'unsigned short'
100
-
102
+ typealias 'stbi_us', 'unsigned short'
101
103
 
102
104
  # function
103
105
  @@lib_signature.each do |sig|
106
+
104
107
  begin
105
108
  extern sig
106
109
  rescue
107
110
  $stderr.puts("[Warning] Failed to import #{sig}.") if output_error
108
111
  end
112
+
109
113
  end
110
114
 
111
- @@glfw_import_done = true
115
+ @@stbi_image_import_done = true
116
+
112
117
  end
113
-
114
- end
115
-
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.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Keresztes
@@ -10,14 +10,19 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-01-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |-
14
- Beta Version!!! Will be developed! So far compatible with: stbi_load, stbi_set_flip_vertically_on_load(). For an easier
15
- soulution, I choose fiddle as function importer from the dll (You should give the dll libary with the .load_lib(lib, path) function
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)"
16
18
  email: ''
17
19
  executables: []
18
20
  extensions: []
19
21
  extra_rdoc_files: []
20
22
  files:
23
+ - README.md
24
+ - dlls/stbDLL_x64.dll
25
+ - dlls/stbDLL_x86.dll
21
26
  - lib/stbimage.rb
22
27
  homepage: https://github.com/fellowchap-samuel/stbimage-ruby
23
28
  licenses: