RGB565 Native Decoding Support
This commit is contained in:
@@ -2,6 +2,15 @@
|
||||
#include <stdint.h>
|
||||
#include <ruby.h>
|
||||
#include "astc.h"
|
||||
#include "rgb.h"
|
||||
|
||||
static VALUE rb_decode_rgb565(VALUE self, VALUE rb_data, VALUE size, VALUE big) {
|
||||
uint8_t *image = (uint8_t*)malloc(FIX2LONG(size) * 3);
|
||||
decode_rgb565((uint16_t*)RSTRING_PTR(rb_data), FIX2INT(size), RTEST(big), image);
|
||||
VALUE ret = rb_str_new((char*)image, FIX2LONG(size) * 3);
|
||||
free(image);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static VALUE rb_decode_astc(VALUE self, VALUE rb_data, VALUE w, VALUE h, VALUE bw, VALUE bh) {
|
||||
const uint8_t *data = (uint8_t*)RSTRING_PTR(rb_data);
|
||||
@@ -16,4 +25,5 @@ void Init_native() {
|
||||
VALUE mMikunyan = rb_define_module("Mikunyan");
|
||||
VALUE mDecodeHelper = rb_define_module_under(mMikunyan, "DecodeHelper");
|
||||
rb_define_module_function(mDecodeHelper, "decode_astc", rb_decode_astc, 5);
|
||||
rb_define_module_function(mDecodeHelper, "decode_rgb565", rb_decode_rgb565, 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user