bare-jpeg 1.0.0 → 1.0.2
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 +10 -11
- package/package.json +1 -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
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
#include <js.h>
|
|
5
5
|
#include <setjmp.h>
|
|
6
6
|
#include <stdlib.h>
|
|
7
|
-
#include <utf.h>
|
|
8
7
|
|
|
9
8
|
typedef struct {
|
|
10
9
|
struct jpeg_error_mgr handle;
|
|
@@ -41,9 +40,9 @@ bare_jpeg_decode(js_env_t *env, js_callback_info_t *info) {
|
|
|
41
40
|
|
|
42
41
|
assert(argc == 1);
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
uint8_t *jpeg;
|
|
45
44
|
size_t len;
|
|
46
|
-
err = js_get_typedarray_info(env, argv[0], NULL, &jpeg, &len, NULL, NULL);
|
|
45
|
+
err = js_get_typedarray_info(env, argv[0], NULL, (void **) &jpeg, &len, NULL, NULL);
|
|
47
46
|
assert(err == 0);
|
|
48
47
|
|
|
49
48
|
bare_jpeg_error_t error;
|
|
@@ -98,8 +97,8 @@ bare_jpeg_decode(js_env_t *env, js_callback_info_t *info) {
|
|
|
98
97
|
|
|
99
98
|
js_value_t *buffer;
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
err = js_create_unsafe_arraybuffer(env, len, &data, &buffer);
|
|
100
|
+
uint8_t *data;
|
|
101
|
+
err = js_create_unsafe_arraybuffer(env, len, (void **) &data, &buffer);
|
|
103
102
|
assert(err == 0);
|
|
104
103
|
|
|
105
104
|
err = js_set_named_property(env, result, "data", buffer);
|
|
@@ -143,8 +142,8 @@ bare_jpeg_encode(js_env_t *env, js_callback_info_t *info) {
|
|
|
143
142
|
|
|
144
143
|
assert(argc == 4);
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
err = js_get_typedarray_info(env, argv[0], NULL, &data, NULL, NULL, NULL);
|
|
145
|
+
uint8_t *data;
|
|
146
|
+
err = js_get_typedarray_info(env, argv[0], NULL, (void **) &data, NULL, NULL, NULL);
|
|
148
147
|
assert(err == 0);
|
|
149
148
|
|
|
150
149
|
int64_t width;
|
|
@@ -167,8 +166,8 @@ bare_jpeg_encode(js_env_t *env, js_callback_info_t *info) {
|
|
|
167
166
|
|
|
168
167
|
jpeg_create_compress(&encoder);
|
|
169
168
|
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
uint8_t *jpeg = NULL;
|
|
170
|
+
unsigned long len = 0;
|
|
172
171
|
jpeg_mem_dest(&encoder, &jpeg, &len);
|
|
173
172
|
|
|
174
173
|
encoder.image_width = width;
|
|
@@ -194,10 +193,10 @@ bare_jpeg_encode(js_env_t *env, js_callback_info_t *info) {
|
|
|
194
193
|
|
|
195
194
|
jpeg_start_compress(&encoder, true);
|
|
196
195
|
|
|
197
|
-
|
|
196
|
+
uint8_t *dst = malloc(width * 3);
|
|
198
197
|
|
|
199
198
|
while (encoder.next_scanline < encoder.image_height) {
|
|
200
|
-
const
|
|
199
|
+
const uint8_t *src = data + encoder.next_scanline * width * 4;
|
|
201
200
|
|
|
202
201
|
for (int x = 0; x < width; x++) {
|
|
203
202
|
dst[x * 3 + 0] = src[x * 4 + 0];
|
package/package.json
CHANGED
|
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
|