bare-jpeg 1.1.4 → 1.1.6
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.
- package/binding.c +12 -2
- package/cmake/ports/libjpeg/port.cmake +30 -0
- package/package.json +2 -1
- package/prebuilds/android-arm/bare-jpeg.bare +0 -0
- package/prebuilds/android-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/android-ia32/bare-jpeg.bare +0 -0
- package/prebuilds/android-x64/bare-jpeg.bare +0 -0
- package/prebuilds/darwin-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/darwin-x64/bare-jpeg.bare +0 -0
- package/prebuilds/ios-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-jpeg.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-jpeg.bare +0 -0
- package/prebuilds/linux-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/linux-x64/bare-jpeg.bare +0 -0
- package/prebuilds/win32-arm64/bare-jpeg.bare +0 -0
- package/prebuilds/win32-x64/bare-jpeg.bare +0 -0
package/binding.c
CHANGED
|
@@ -75,7 +75,7 @@ bare_jpeg_decode(js_env_t *env, js_callback_info_t *info) {
|
|
|
75
75
|
|
|
76
76
|
if (decoder.out_color_space == JCS_GRAYSCALE) decoder.out_color_space = JCS_RGB;
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
jpeg_calc_output_dimensions(&decoder);
|
|
79
79
|
|
|
80
80
|
JDIMENSION width = decoder.output_width;
|
|
81
81
|
JDIMENSION height = decoder.output_height;
|
|
@@ -99,6 +99,8 @@ bare_jpeg_decode(js_env_t *env, js_callback_info_t *info) {
|
|
|
99
99
|
return NULL;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
jpeg_start_decompress(&decoder);
|
|
103
|
+
|
|
102
104
|
js_value_t *result;
|
|
103
105
|
err = js_create_object(env, &result);
|
|
104
106
|
assert(err == 0);
|
|
@@ -171,7 +173,8 @@ bare_jpeg_encode(js_env_t *env, js_callback_info_t *info) {
|
|
|
171
173
|
assert(argc == 4);
|
|
172
174
|
|
|
173
175
|
uint8_t *data;
|
|
174
|
-
|
|
176
|
+
size_t data_len;
|
|
177
|
+
err = js_get_typedarray_info(env, argv[0], NULL, (void **) &data, &data_len, NULL, NULL);
|
|
175
178
|
assert(err == 0);
|
|
176
179
|
|
|
177
180
|
int64_t width;
|
|
@@ -193,6 +196,13 @@ bare_jpeg_encode(js_env_t *env, js_callback_info_t *info) {
|
|
|
193
196
|
return NULL;
|
|
194
197
|
}
|
|
195
198
|
|
|
199
|
+
if ((uint64_t) width * height * 4 > data_len) {
|
|
200
|
+
err = js_throw_error(env, NULL, "RGBA data is too short for the JPEG dimensions");
|
|
201
|
+
assert(err == 0);
|
|
202
|
+
|
|
203
|
+
return NULL;
|
|
204
|
+
}
|
|
205
|
+
|
|
196
206
|
bare_jpeg_error_t error;
|
|
197
207
|
|
|
198
208
|
struct jpeg_compress_struct encoder;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
include_guard(GLOBAL)
|
|
2
|
+
|
|
3
|
+
if(WIN32)
|
|
4
|
+
set(lib lib/jpeg-static.lib)
|
|
5
|
+
else()
|
|
6
|
+
set(lib lib/libjpeg.a)
|
|
7
|
+
endif()
|
|
8
|
+
|
|
9
|
+
declare_port(
|
|
10
|
+
"github:libjpeg-turbo/libjpeg-turbo#3.2.0"
|
|
11
|
+
jpeg
|
|
12
|
+
BYPRODUCTS ${lib}
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
add_library(jpeg STATIC IMPORTED GLOBAL)
|
|
16
|
+
|
|
17
|
+
add_dependencies(jpeg ${jpeg})
|
|
18
|
+
|
|
19
|
+
set_target_properties(
|
|
20
|
+
jpeg
|
|
21
|
+
PROPERTIES
|
|
22
|
+
IMPORTED_LOCATION "${jpeg_PREFIX}/${lib}"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
file(MAKE_DIRECTORY "${jpeg_PREFIX}/include")
|
|
26
|
+
|
|
27
|
+
target_include_directories(
|
|
28
|
+
jpeg
|
|
29
|
+
INTERFACE "${jpeg_PREFIX}/include"
|
|
30
|
+
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-jpeg",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "JPEG support for Bare",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"binding.c",
|
|
12
12
|
"binding.js",
|
|
13
13
|
"CMakeLists.txt",
|
|
14
|
+
"cmake",
|
|
14
15
|
"prebuilds"
|
|
15
16
|
],
|
|
16
17
|
"addon": true,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|