stbimage 0.1.0
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 +7 -0
- data/lib/stbimage.rb +115 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c4f132fbe26ee47f2e71b0ddfda922bcc700ece8c93f71fd9ae8f2ae4a04f248
|
4
|
+
data.tar.gz: 91feae88f875464129fd6d8ebeea3492cd95ab1066e815d2a9a069be3baa3b83
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 475cb4a5ed73f0c48f5116607718842cdd484b3fa18107a49deb4a7cf8d4017ad0f38c448b6895f4345e4ba91b7e99184e6855394eda0109aa04c3143bdd9feb
|
7
|
+
data.tar.gz: c294143e12251d61124adcb39f97c2e4bf73b2cc0eca4744313d0b9fb7d18822e16a11d5401018f3a678a9ec84cc3cdf721d4d0f4f929cd08ef234419ca08786
|
data/lib/stbimage.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
|
2
|
+
require 'fiddle/import'
|
3
|
+
|
4
|
+
module STBIMAGE
|
5
|
+
|
6
|
+
extend Fiddle::Importer
|
7
|
+
|
8
|
+
STBIMAGE_FUNCTIONS_MAP = {}
|
9
|
+
def self.extern(signature, *opts)
|
10
|
+
symname, ctype, argtype = parse_signature(signature, @type_alias)
|
11
|
+
opt = parse_bind_options(opts)
|
12
|
+
f = import_function(symname, ctype, argtype, opt[:call_type])
|
13
|
+
name = symname.gsub(/@.+/,'')
|
14
|
+
STBIMAGE_FUNCTIONS_MAP[name] = f
|
15
|
+
begin
|
16
|
+
/^(.+?):(\d+)/ =~ caller.first
|
17
|
+
file, line = $1, $2.to_i
|
18
|
+
rescue
|
19
|
+
file, line = __FILE__, __LINE__+3
|
20
|
+
end
|
21
|
+
args_str="*args"
|
22
|
+
module_eval(<<-EOS, file, line)
|
23
|
+
def #{name}(*args, &block)
|
24
|
+
STBIMAGE_FUNCTIONS_MAP['#{name}'].call(*args,&block)
|
25
|
+
end
|
26
|
+
EOS
|
27
|
+
module_function(name)
|
28
|
+
f
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
@@glfw_import_done = false
|
33
|
+
|
34
|
+
# Load native library.
|
35
|
+
def self.load_lib(lib = nil, path = nil, output_error = false)
|
36
|
+
if lib == nil && path == nil
|
37
|
+
lib, path = 'stbDLL.dll', Dir.pwd
|
38
|
+
end
|
39
|
+
|
40
|
+
if path
|
41
|
+
dlload (path + '/' + lib)
|
42
|
+
else
|
43
|
+
dlload (lib)
|
44
|
+
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)
|
51
|
+
end
|
52
|
+
|
53
|
+
@@lib_signature = [
|
54
|
+
'void stbi_convert_iphone_png_to_rgb(int)',
|
55
|
+
'const char *stbi_failure_reason(void)',
|
56
|
+
'void stbi_hdr_to_ldr_gamma(float)',
|
57
|
+
'void stbi_hdr_to_ldr_scale(float)',
|
58
|
+
'void stbi_image_free(void*)',
|
59
|
+
'int stbi_info(char const* , int*, int*, int*)',
|
60
|
+
# 'int stbi_info_from_callbacks(stbi_io_callbacks const*, void*, int*, int*, comp*)'
|
61
|
+
# 'stbi_info_from_file'
|
62
|
+
# 'stbi_info_from_memory'
|
63
|
+
# 'stbi_is_16_bit'
|
64
|
+
# 'stbi_is_16_bit_from_callbacks'
|
65
|
+
# 'stbi_is_16_bit_from_file'
|
66
|
+
# 'stbi_is_16_bit_from_memory'
|
67
|
+
# 'stbi_is_hdr'
|
68
|
+
# 'stbi_is_hdr_from_callbacks'
|
69
|
+
# 'stbi_is_hdr_from_file'
|
70
|
+
# 'stbi_is_hdr_from_memory'
|
71
|
+
# 'stbi_ldr_to_hdr_gamma'
|
72
|
+
# 'stbi_ldr_to_hdr_scale'
|
73
|
+
'stbi_uc* stbi_load(char const*, int*, int*, int*, int)',
|
74
|
+
# 'stbi_load_16'
|
75
|
+
# 'stbi_load_16_from_callbacks'
|
76
|
+
# 'stbi_load_16_from_memory'
|
77
|
+
# 'stbi_load_from_callbacks'
|
78
|
+
# 'stbi_load_from_file'
|
79
|
+
# 'stbi_load_from_file_16'
|
80
|
+
# 'stbi_load_from_memory'
|
81
|
+
# 'stbi_load_gif_from_memory'
|
82
|
+
# 'stbi_loadf'
|
83
|
+
# 'stbi_loadf_from_callbacks'
|
84
|
+
# 'stbi_loadf_from_file'
|
85
|
+
# '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'
|
95
|
+
]
|
96
|
+
|
97
|
+
def self.import_symbols(output_error = false)
|
98
|
+
typealias 'stbi_uc', 'unsigned char'
|
99
|
+
typealias 'stbi_us', 'unsigned short'
|
100
|
+
|
101
|
+
|
102
|
+
# function
|
103
|
+
@@lib_signature.each do |sig|
|
104
|
+
begin
|
105
|
+
extern sig
|
106
|
+
rescue
|
107
|
+
$stderr.puts("[Warning] Failed to import #{sig}.") if output_error
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
@@glfw_import_done = true
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stbimage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Keresztes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-09 00:00:00.000000000 Z
|
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
|
16
|
+
email: ''
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/stbimage.rb
|
22
|
+
homepage: ''
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.1.4
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Bindings for the often used header stb_image.h
|
45
|
+
test_files: []
|