stbimage 0.6.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -26
- data/lib/stbimage.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69de01a0ee15b7dc3ce3827d250b061b62d56a3348d49b4cf01f53773439c9ab
|
4
|
+
data.tar.gz: bd2e49f16a3aad172a99645012af9cab9e8cde0a6cb0eef7bb8250ddd888183d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbac49f49b65b30ff3340a8d3d8e2dbb7fb551dae3286255e8fac24282766e8fbc2d3fc9dd43c5082ef9020a0f8aded035064f884cee4e2e7618d115ab85af6c
|
7
|
+
data.tar.gz: 8c31f5a515a4ea94524dfcdbcee97821792655ee8c227f97dab2663ac89527d3fe8820f899aaeaafdf67253c417dee306686914527cc09256fa0220b12fcab7f
|
data/README.md
CHANGED
@@ -1,35 +1,18 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# stb-image ruby bindings
|
4
2
|
|
5
3
|
Ruby binding of stb-image.h
|
6
4
|
|
7
|
-
|
8
|
-
**Added support for Linux (32, 64, arm)**
|
9
|
-
|
10
|
-
* ### Supports (so far): ###
|
5
|
+
* ### Supports: ###
|
11
6
|
<br>
|
12
7
|
|
13
8
|
* **stbi_load** (Default image loader)
|
9
|
+
* **stbi_load_from_memory**
|
14
10
|
* **stbi_load_16**
|
15
11
|
* **stbi_loadf** (For `.hdr` images)
|
16
12
|
* **stbi_info**
|
17
13
|
* **stbi_image_free**
|
18
|
-
* **stbi_failure_reason**
|
19
14
|
* **stbi_set_flip_vertically_on_load**
|
20
|
-
*
|
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**
|
15
|
+
* and more...
|
33
16
|
|
34
17
|
|
35
18
|
<br>
|
@@ -65,7 +48,7 @@ If you want to compile the shared libary yourself, Use the instruction below (ot
|
|
65
48
|
|
66
49
|
# Precompiled shared libs (.dll, .so)
|
67
50
|
|
68
|
-
You can find it under [dlls](dlls) folder, but they are also included in the gem
|
51
|
+
You can find it under [dlls](lib/dlls) folder, but they are also included in the gem
|
69
52
|
|
70
53
|
<br>
|
71
54
|
|
@@ -97,13 +80,92 @@ nr_channels = ' ' * 4
|
|
97
80
|
|
98
81
|
data = STBIMAGE.stbi_load("blue-poly.jpg", width, height, nr_channels, 0)
|
99
82
|
|
100
|
-
|
83
|
+
data # the retrieved image data
|
84
|
+
|
85
|
+
width = width.unpack1('L')
|
86
|
+
height height.unpack1('L')
|
87
|
+
nr_channels = nr_channels.unpack1('L')
|
101
88
|
|
102
|
-
|
103
|
-
|
104
|
-
|
89
|
+
|
90
|
+
|
91
|
+
# The retrieved data can be used in OpenGL for instance.
|
92
|
+
# glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data)
|
93
|
+
|
94
|
+
stbi_image_free(data)
|
105
95
|
```
|
106
96
|
|
97
|
+
<br>
|
98
|
+
|
99
|
+
# Function list and examples:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
include STBIMAGE
|
103
|
+
|
104
|
+
# 1. stbi_load(path_to_file, width_ptr, height_ptr, num_channels_ptr, desired_channels)
|
105
|
+
|
106
|
+
width = ' ' * 4 # width_ptr
|
107
|
+
height = ' ' * 4 # height_ptr
|
108
|
+
nr_channels = ' ' * 4 # num_channels_ptr
|
109
|
+
|
110
|
+
data = stbi_load("blue-poly.jpg", width, height, nr_channels, 0)
|
111
|
+
|
112
|
+
# retrieve the values from the pointers
|
113
|
+
width = width.unpack1('L')
|
114
|
+
height = height.unpack1('L')
|
115
|
+
nr_channels = nr_channels.unpack1('L')
|
116
|
+
```
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
include STBIMAGE
|
120
|
+
|
121
|
+
# 2. stbi_load_from_memory(ptr_to_image_data_array, image_array_size_in_bytes, width_ptr, height_ptr, num_channels_ptr, desired_channels)
|
122
|
+
|
123
|
+
white_texture_raw = [
|
124
|
+
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
|
125
|
+
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7A, 0x7A,
|
126
|
+
0xF4, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00,
|
127
|
+
0x00, 0x2F, 0x49, 0x44, 0x41, 0x54, 0x58, 0x47, 0xED, 0xD0, 0x41, 0x11, 0x00, 0x00, 0x0C, 0xC2,
|
128
|
+
0xB0, 0xE1, 0x5F, 0x34, 0x93, 0xC1, 0x27, 0x55, 0xD0, 0x4B, 0xDA, 0xF6, 0x86, 0xC5, 0x00, 0x01,
|
129
|
+
0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0xB0, 0x16,
|
130
|
+
0x78, 0x31, 0x4C, 0x7F, 0xA1, 0xF9, 0xB6, 0x23, 0xF9, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E,
|
131
|
+
0x44, 0xAE, 0x42, 0x60, 0x82
|
132
|
+
]
|
133
|
+
|
134
|
+
texture_size = white_texture_raw.size
|
135
|
+
texture_ptr = Fiddle::Pointer.to_ptr(white_texture_raw.pack('C*'))
|
136
|
+
|
137
|
+
width = ' ' * 4 # width_ptr
|
138
|
+
height = ' ' * 4 # height_ptr
|
139
|
+
nr_channels = ' ' * 4 # num_channels_ptr
|
140
|
+
|
141
|
+
data = stbi_load_from_file(texture_ptr, texture_size, width, height, nr_channels, 0)
|
142
|
+
|
143
|
+
# retrieve the values from the pointers
|
144
|
+
width = width.unpack1('L')
|
145
|
+
height = height.unpack1('L')
|
146
|
+
nr_channels = nr_channels.unpack1('L')
|
147
|
+
```
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
include STBIMAGE
|
151
|
+
|
152
|
+
# 3. stbi_set_flip_vertically_on_load(value)
|
153
|
+
# before getting reading the image:
|
154
|
+
|
155
|
+
stbi_set_flip_vertically_on_load(1) # flips the image vertically on load
|
156
|
+
stbi_set_flip_vertically_on_load(0) # disable flipping
|
157
|
+
```
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
include STBIMAGE
|
161
|
+
|
162
|
+
# 4. stbi_image_free(img_data)
|
163
|
+
# freeing up the image in memory after we loaded the image. It's essential in order to avoid big memory usage.
|
164
|
+
|
165
|
+
stbi_image_free(data)
|
166
|
+
```
|
167
|
+
|
168
|
+
|
107
169
|
<br>
|
108
170
|
|
109
171
|
# Credit
|
data/lib/stbimage.rb
CHANGED
@@ -113,7 +113,7 @@ module STBIMAGE
|
|
113
113
|
# 'stbi_load_from_callbacks'
|
114
114
|
# 'stbi_load_from_file'
|
115
115
|
# 'stbi_load_from_file_16'
|
116
|
-
|
116
|
+
'stbi_uc const* stbi_load_from_memory(stbi_uc const*, int, int*, int*, int*, int)',
|
117
117
|
# 'stbi_load_gif_from_memory'
|
118
118
|
'float* stbi_loadf(char const*, int*, int*, int*, int)',
|
119
119
|
# 'stbi_loadf_from_callbacks'
|
metadata
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stbimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Keresztes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
|
16
|
-
Linux or ARM"
|
13
|
+
description: 'A practical image importer/loader. It wraps stb_image.h (ver:2.26 -2020.07.13-).
|
14
|
+
Supported image formats are: JPEG, PNG, TGA, BMP, PSD, GIF(not animation), HDR,
|
15
|
+
PIC, PNM. Checkout the Homepage for usage in Windows, MacOs, Linux or ARM'
|
17
16
|
email: ''
|
18
17
|
executables: []
|
19
18
|
extensions: []
|
@@ -48,8 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
47
|
- !ruby/object:Gem::Version
|
49
48
|
version: '0'
|
50
49
|
requirements: []
|
51
|
-
rubygems_version: 3.1.
|
50
|
+
rubygems_version: 3.1.6
|
52
51
|
signing_key:
|
53
52
|
specification_version: 4
|
54
|
-
summary: Bindings
|
53
|
+
summary: Bindings of the often used header stb_image.h
|
55
54
|
test_files: []
|