28static size_t div_up(
size_t dividend,
size_t divisor) {
29 return dividend / divisor + (dividend % divisor != 0);
33 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
36 return div_up(original_size, 3) * 4;
44 while (data_i < size) {
47 unsigned char d0 =
data[data_i];
51 unsigned char d1 = data_i + 1 < size ?
data[data_i + 1] : 0;
55 if (size <= data_i + 1) {
59 unsigned char d2 = data_i + 2 < size ?
data[data_i + 2] : 0;
63 if (size <= data_i + 2) {
74 while (buf_i % 4 != 0) {
82 unsigned height,
bool is_compressed) {
83 const size_t chunk_size = 4096;
89 int has_next_chunk =
offset + chunk_size <= size;
91 printf(
"\033_Ga=T,f=32,s=%u,v=%u%s%s;", width, height,
92 chunk_size < size ?
",m=1" :
"", is_compressed ?
",o=z" :
"");
94 printf(
"\033_Gm=%d;", has_next_chunk);
97 size_t this_chunk_size = has_next_chunk ? chunk_size : size -
offset;
98 fwrite(output +
offset, this_chunk_size, 1, stdout);
108 unsigned char *imagedata = job->
imagedata;
125static int zlib_compress(
unsigned char *source, uLong source_len,
126 unsigned char **dest,
size_t *dest_len) {
127 uLong dest_cap = compressBound(source_len);
130 const int ret =
compress(*dest, &dest_cap, source, source_len);
131 *dest_len = dest_cap;
135static void zkitty_format(
GVJ_t *job) {
136 unsigned char *imagedata = job->
imagedata;
142 int ret = zlib_compress(imagedata, imagedata_size, &zbuf, &zsize);
164 {1,
"kittyz:cairo", 1, &device_engine_zkitty, &device_features_zkitty},
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
static double compress(info *nl, int nn)
Arithmetic helper functions.
static void argb2rgba(size_t width, size_t height, unsigned char *data)
swig_ptr_object_handlers offset
#define GVDEVICE_DOES_TRUECOLOR
static void kitty_format(GVJ_t *job)
static char * base64_encode(const unsigned char *data, size_t size)
static gvdevice_engine_t device_engine_kitty
static size_t base64_encoded_size(size_t original_size)
static size_t div_up(size_t dividend, size_t divisor)
static const char base64_alphabet[]
gvplugin_installed_t gvdevice_types_kitty[]
static gvdevice_features_t device_features_kitty
static void kitty_write(unsigned char *data, size_t data_size, unsigned width, unsigned height, bool is_compressed)
unsigned char * imagedata
location of imagedata
void(* format)(GVJ_t *firstjob)
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t