module DNN::Stb
Constants
- STBIR_ALPHA_CHANNEL_NONE
- STBIR_EDGE_CLAMP
- STBIR_EDGE_REFLECT
- STBIR_EDGE_WRAP
- STBIR_EDGE_ZERO
- STBIR_FLAG_ALPHA_PREMULTIPLIED
- STBIR_FLAG_ALPHA_USES_COLORSPACE
Public Class Methods
stbi_load(p1, p2)
click to toggle source
static VALUE rb_stbi_load(VALUE self, VALUE rb_filename, VALUE rb_req_comp) { char* filename = StringValuePtr(rb_filename); int32_t x, y, n; int32_t req_comp = FIX2INT(rb_req_comp); uint8_t* data; int32_t ch; VALUE rb_x, rb_y, rb_n; VALUE rb_data; data = stbi_load(filename, &x, &y, &n, req_comp); rb_x = INT2FIX(x); rb_y = INT2FIX(y); rb_n = INT2FIX(n); ch = req_comp == 0 ? n : req_comp; rb_data = rb_str_new((char*)data, y * x * ch); stbi_image_free(data); return rb_ary_new3(4, rb_data, rb_x, rb_y, rb_n); }
stbi_write_bmp(p1, p2, p3, p4, p5)
click to toggle source
static VALUE rb_stbi_write_bmp(VALUE self, VALUE rb_filename, VALUE rb_w, VALUE rb_h, VALUE rb_comp, VALUE rb_data) { char* filename = StringValuePtr(rb_filename); int32_t w = FIX2INT(rb_w); int32_t h = FIX2INT(rb_h); int32_t comp = FIX2INT(rb_comp); uint8_t* data = (uint8_t*)StringValuePtr(rb_data); int32_t result; result = stbi_write_bmp(filename, w, h, comp, data); return INT2FIX(result); }
stbi_write_hdr(p1, p2, p3, p4, p5)
click to toggle source
static VALUE rb_stbi_write_hdr(VALUE self, VALUE rb_filename, VALUE rb_w, VALUE rb_h, VALUE rb_comp, VALUE rb_data) { char* filename = StringValuePtr(rb_filename); int32_t w = FIX2INT(rb_w); int32_t h = FIX2INT(rb_h); int32_t comp = FIX2INT(rb_comp); float* data = (float*)StringValuePtr(rb_data); int32_t result; result = stbi_write_hdr(filename, w, h, comp, data); return INT2FIX(result); }
stbi_write_jpg(p1, p2, p3, p4, p5, p6)
click to toggle source
static VALUE rb_stbi_write_jpg(VALUE self, VALUE rb_filename, VALUE rb_w, VALUE rb_h, VALUE rb_comp, VALUE rb_data, VALUE rb_quality) { char* filename = StringValuePtr(rb_filename); int32_t w = FIX2INT(rb_w); int32_t h = FIX2INT(rb_h); int32_t comp = FIX2INT(rb_comp); uint8_t* data = (uint8_t*)StringValuePtr(rb_data); int32_t quality = FIX2INT(rb_quality); int32_t result; result = stbi_write_jpg(filename, w, h, comp, data, quality); return INT2FIX(result); }
stbi_write_png(p1, p2, p3, p4, p5, p6)
click to toggle source
static VALUE rb_stbi_write_png(VALUE self, VALUE rb_filename, VALUE rb_w, VALUE rb_h, VALUE rb_comp, VALUE rb_data, VALUE rb_stride_in_bytes) { char* filename = StringValuePtr(rb_filename); int32_t w = FIX2INT(rb_w); int32_t h = FIX2INT(rb_h); int32_t comp = FIX2INT(rb_comp); uint8_t* data = (uint8_t*)StringValuePtr(rb_data); int32_t stride_in_bytes = FIX2INT(rb_stride_in_bytes); int32_t result; result = stbi_write_png(filename, w, h, comp, data, stride_in_bytes); return INT2FIX(result); }
stbi_write_tga(p1, p2, p3, p4, p5)
click to toggle source
static VALUE rb_stbi_write_tga(VALUE self, VALUE rb_filename, VALUE rb_w, VALUE rb_h, VALUE rb_comp, VALUE rb_data) { char* filename = StringValuePtr(rb_filename); int32_t w = FIX2INT(rb_w); int32_t h = FIX2INT(rb_h); int32_t comp = FIX2INT(rb_comp); uint8_t* data = (uint8_t*)StringValuePtr(rb_data); int32_t result; result = stbi_write_tga(filename, w, h, comp, data); return INT2FIX(result); }
stbir_resize_uint8(p1, p2, p3, p4, p5, p6, p7, p8)
click to toggle source
static VALUE rb_stbir_resize_uint8(VALUE self, VALUE rb_input_pixels, VALUE rb_input_w, VALUE rb_input_h, VALUE rb_input_stride_in_bytes, VALUE rb_output_w, VALUE rb_output_h, VALUE rb_output_stride_in_bytes, VALUE rb_num_channels) { uint8_t* input_pixels = (uint8_t*)StringValuePtr(rb_input_pixels); int32_t input_w = FIX2INT(rb_input_w); int32_t input_h = FIX2INT(rb_input_h); int32_t input_stride_in_bytes = FIX2INT(rb_input_stride_in_bytes); int32_t output_w = FIX2INT(rb_output_w); int32_t output_h = FIX2INT(rb_output_h); int32_t output_stride_in_bytes = FIX2INT(rb_output_stride_in_bytes); int32_t num_channels = FIX2INT(rb_num_channels); uint8_t* output_pixels; VALUE rb_output_pixels; int32_t result; const int32_t output_size = output_h * output_w * num_channels; output_pixels = (uint8_t*)malloc(output_size); result = stbir_resize_uint8(input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, num_channels); rb_output_pixels = rb_str_new((char*)output_pixels, output_size); free(output_pixels); return rb_ary_new3(2, rb_output_pixels, INT2FIX(result)); }
stbir_resize_uint8_srgb(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
click to toggle source
static VALUE rb_stbir_resize_uint8_srgb(VALUE self, VALUE rb_input_pixels, VALUE rb_input_w, VALUE rb_input_h, VALUE rb_input_stride_in_bytes, VALUE rb_output_w, VALUE rb_output_h, VALUE rb_output_stride_in_bytes, VALUE rb_num_channels, VALUE rb_alpha_channel, VALUE rb_flags) { uint8_t* input_pixels = (uint8_t*)StringValuePtr(rb_input_pixels); int32_t input_w = FIX2INT(rb_input_w); int32_t input_h = FIX2INT(rb_input_h); int32_t input_stride_in_bytes = FIX2INT(rb_input_stride_in_bytes); int32_t output_w = FIX2INT(rb_output_w); int32_t output_h = FIX2INT(rb_output_h); int32_t output_stride_in_bytes = FIX2INT(rb_output_stride_in_bytes); int32_t num_channels = FIX2INT(rb_num_channels); int32_t alpha_channel = FIX2INT(rb_alpha_channel); int32_t flags = FIX2INT(rb_flags); uint8_t* output_pixels; VALUE rb_output_pixels; int32_t result; const int32_t output_size = output_h * output_w * num_channels; output_pixels = (uint8_t*)malloc(output_size); result = stbir_resize_uint8_srgb(input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, num_channels, alpha_channel, flags); rb_output_pixels = rb_str_new((char*)output_pixels, output_size); free(output_pixels); return rb_ary_new3(2, rb_output_pixels, INT2FIX(result)); }
stbir_resize_uint8_srgb_edgemode(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)
click to toggle source
static VALUE rb_stbir_resize_uint8_srgb_edgemode(VALUE self, VALUE rb_input_pixels, VALUE rb_input_w, VALUE rb_input_h, VALUE rb_input_stride_in_bytes, VALUE rb_output_w, VALUE rb_output_h, VALUE rb_output_stride_in_bytes, VALUE rb_num_channels, VALUE rb_alpha_channel, VALUE rb_flags, VALUE rb_edge_wrap_mode) { uint8_t* input_pixels = (uint8_t*)StringValuePtr(rb_input_pixels); int32_t input_w = FIX2INT(rb_input_w); int32_t input_h = FIX2INT(rb_input_h); int32_t input_stride_in_bytes = FIX2INT(rb_input_stride_in_bytes); int32_t output_w = FIX2INT(rb_output_w); int32_t output_h = FIX2INT(rb_output_h); int32_t output_stride_in_bytes = FIX2INT(rb_output_stride_in_bytes); int32_t num_channels = FIX2INT(rb_num_channels); int32_t alpha_channel = FIX2INT(rb_alpha_channel); int32_t flags = FIX2INT(rb_flags); stbir_edge edge_wrap_mode = (stbir_edge)FIX2INT(rb_edge_wrap_mode); uint8_t* output_pixels; VALUE rb_output_pixels; int32_t result; const int32_t output_size = output_h * output_w * num_channels; output_pixels = (uint8_t*)malloc(output_size); result = stbir_resize_uint8_srgb_edgemode(input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, num_channels, alpha_channel, flags, edge_wrap_mode); rb_output_pixels = rb_str_new((char*)output_pixels, output_size); free(output_pixels); return rb_ary_new3(2, rb_output_pixels, INT2FIX(result)); }