value lime_lzma_encode (value buffer) { Bytes data = Bytes (buffer); Bytes result; LZMA::Encode (&data, &result); return result.Value (); }
value lime_image_encode (value buffer, value type, value quality) { ImageBuffer imageBuffer = ImageBuffer (buffer); Bytes data; switch (val_int (type)) { case 0: #ifdef LIME_PNG if (PNG::Encode (&imageBuffer, &data)) { //delete imageBuffer.data; return data.Value (); } #endif break; case 1: #ifdef LIME_JPEG if (JPEG::Encode (&imageBuffer, &data, val_int (quality))) { //delete imageBuffer.data; return data.Value (); } #endif break; default: break; } //delete imageBuffer.data; return alloc_null (); }
value lime_bytes_from_data_pointer (double data, int length) { intptr_t ptr = (intptr_t)data; Bytes bytes = Bytes (length); if (ptr) { memcpy (bytes.Data (), (const void*)ptr, length); } return bytes.Value (); }
value lime_text_layout_position (value textHandle, value fontHandle, value size, value textString, value data) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) TextLayout *text = (TextLayout*)(intptr_t)val_float (textHandle); Font *font = (Font*)(intptr_t)val_float (fontHandle); Bytes bytes = Bytes (data); text->Position (font, val_int (size), val_string (textString), &bytes); return bytes.Value (); #endif return alloc_null (); }
value lime_bytes_from_data_pointer (value data, value length) { int size = val_int (length); intptr_t ptr = (intptr_t)val_float (data); Bytes bytes = Bytes (size); if (ptr) { memcpy (bytes.Data (), (const void*)ptr, size); } return bytes.Value (); }
value lime_gzip_decompress (value buffer) { #ifdef LIME_ZLIB Bytes data; data.Set (buffer); Bytes result; Zlib::Decompress (GZIP, &data, &result); return result.Value (); #else return alloc_null (); #endif }
value lime_deflate_compress (value buffer) { #ifdef LIME_ZLIB Bytes data; data.Set (buffer); Bytes result; Zlib::Compress (DEFLATE, &data, &result); return result.Value (); #else return alloc_null(); #endif }
value lime_lzma_decompress (value buffer) { #ifdef LIME_LZMA Bytes data; data.Set (buffer); Bytes result; LZMA::Decompress (&data, &result); return result.Value (); #else return alloc_null (); #endif }
value lime_text_layout_position (value textHandle, value fontHandle, int size, HxString textString, value data) { #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) TextLayout *text = (TextLayout*)val_data (textHandle); Font *font = (Font*)val_data (fontHandle); Bytes bytes; bytes.Set (data); text->Position (font, size, textString.__s, &bytes); return bytes.Value (); #endif return alloc_null (); }
value lime_bytes_read_file (value path) { Bytes data = Bytes (val_os_string (path)); return data.Value (); }
value lime_bytes_read_file (HxString path) { Bytes data = Bytes (path.__s); return data.Value (); }