diff options
Diffstat (limited to 'adapter/img')
-rw-r--r-- | adapter/img/stbi.nim | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/adapter/img/stbi.nim b/adapter/img/stbi.nim index e4580d5c..f32c7f77 100644 --- a/adapter/img/stbi.nim +++ b/adapter/img/stbi.nim @@ -8,9 +8,11 @@ import utils/twtstr {.passc: "-fno-strict-aliasing".} {.passl: "-fno-strict-aliasing".} -{.compile: "stb_image.c".} +{.compile("stb_image.c", "-O3").} -type stbi_io_callbacks = object +{.push header: "stb_image.h".} + +type stbi_io_callbacks {.importc.} = object read: proc(user: pointer; data: ptr uint8; size: cint): cint {.cdecl.} skip: proc(user: pointer; n: cint) {.cdecl.} eof: proc(user: pointer): cint {.cdecl.} @@ -26,6 +28,8 @@ proc stbi_failure_reason(): cstring {.importc.} proc stbi_image_free(retval_from_stbi_load: pointer) {.importc.} +{.pop.} + proc myRead(user: pointer; data: ptr uint8; size: cint): cint {.cdecl.} = return cint(stdin.readBuffer(data, size)) @@ -41,20 +45,24 @@ proc myEof(user: pointer): cint {.cdecl.} = type stbi_write_func = proc(context, data: pointer; size: cint) {.cdecl.} +{.push header: "stb_image_write.h".} proc stbi_write_png_to_func(fun: stbi_write_func; context: pointer; w, h, comp: cint; data: pointer; stride_in_bytes: cint) {.importc.} proc stbi_write_bmp_to_func(fun: stbi_write_func; context: pointer; w, h, comp: cint; data: pointer) {.importc.} proc stbi_write_jpg_to_func(fun: stbi_write_func; context: pointer; w, h, comp: cint; data: pointer; quality: cint) {.importc.} +{.pop.} proc myWriteFunc(context, data: pointer; size: cint) {.cdecl.} = discard stdout.writeBuffer(data, size) +{.push header: "stb_image_resize.h".} proc stbir_resize_uint8(input_pixels: ptr uint8; input_w, input_h, input_stride_in_bytes: cint; output_pixels: ptr uint8; output_w, output_h, output_stride_in_bytes, num_channels: cint): cint {.importc.} +{.pop.} proc main() = enterNetworkSandbox() |